leesins专题

C. League of Leesins cf1255c (拓扑排序,搜索)

Bob is an avid fan of the video game “League of Leesins”, and today he celebrates as the League of Leesins World Championship comes to an end! The tournament consisted of 𝑛 (𝑛≥5) teams around the w

CodeForces 1255C:League of Leesins 拓扑排序

传送门 题目描述 给出一个排列,每连续3个数取一次,并且3个数的顺序都可以改变和每3个数的排列顺序。 分析 我们会发现,出现在第一个和最后一个的数字,在三元组中也只会出现一次,出现在第二位和倒数第二位的数字,只会出现两次,其余的都会出现三次,所以,我们可以记录每个数字出现的次数,然后每个三元组里面连边,进行拓扑排序即可 需要注意的是,拓扑排序的时候,当入度减为1的时候,会有多个点入队列,

4. League of Leesins

题目链接:League of Leesins 容易注意到只出现一次的数必然可以作为第一个元素,然后从这个三元组开始搜下去就可以得到答案。具体实现方式很多,这里就不写了。 其实这题还有一个比较有趣的做法,可以根据给出的三元组对数字连边,最后进行一次拓扑排序即可。 #include <bits/stdc++.h>using namespace std;const int maxn = 2e5