CF741C - Arpa's overnight party and Mehrdad's silent entering 题意: 有 n 对情侣坐成一个圈,有两种食物Kooft and Zahre-mar,要给每个人分其中一种,要求每对情侣的食物不同,任意连续的三个人必须要有两人食物不同. 求分配方案,无解输出-1 1≤n ≤100000 注意:"Kooft" is something make people die. "Zahre-mar" meaning is…
直接令2i-1和2i的位置不相同,相当于有2n条边,对其进行二分图染色即可(这张图一定不存在奇环). 假设给出的n条关系是A类边,2i-1和2i的边是B类边,可以发现一条路径一定是AB交替(因为A/B的终点一定不可能是A/B的起点),那么环就一定是有等量的A边和B边,即偶环. 1 #include<bits/stdc++.h> 2 using namespace std; 3 #define N 200005 4 struct ji{ 5 int nex,to; 6 }edge[N<&l…
http://codeforces.com/contest/742/problem/E 跪着看题解后才会的. 对于任何一对BF[i]和GF[i] 连接了一条边后,那么他们和隔壁都是不会有边相连的了,这是题目数据保证的.因为BF[i]和GF[i]是唯一确定的嘛. 那么,我们把BF[i]连接去GF[i]的边叫1类边. 然后把2 * i - 1 和 2 * i也连上边,是第二类边. 那么每个顶点的度数都是2,并且都是一条第一类边和一条第二类的. 那么如果有环,也是偶数环,不存在几圈.所以直接染色即可.…
Arpa's loud Owf and Mehrdad's evil plan time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As you have noticed, there are lovely girls in Arpa's land. People in Arpa's land are numbered from 1…
D. Arpa's weak amphitheater and Mehrdad's valuable Hoses Problem Description: Mehrdad wants to invite some Hoses to the palace for a dancing party. Each Hos has some weight wi and some beauty bi. Also each Hos may have some friends. Hoses are divided…
Arpa's weak amphitheater and Mehrdad's valuable Hoses time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Just to remind, girls in Arpa's land are really nice. Mehrdad wants to invite some Hose…
Arpa's loud Owf and Mehrdad's evil plan time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As you have noticed, there are lovely girls in Arpa’s land. People in Arpa's land are numbered from 1…
C. Arpa's loud Owf and Mehrdad's evil plan time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output As you have noticed, there are lovely girls in Arpa’s land. People in Arpa's land are numbered fro…
B. Arpa’s obvious problem and Mehrdad’s terrible solution time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output There are some beautiful girls in Arpa’s land as mentioned before. Once Arpa came u…
D. Arpa's letter-marked tree and Mehrdad's Dokhtar-kosh paths CF741D 题意: 一棵有根树,边上有字母a~v,求每个子树中最长的边,满足这个边上的所有字母重拍后可以构成回文 发明者自己出的题...orz 由于本来知道就是dsu on tree,所以还是想出来了 首先点分治是没法做了,这是有根树 写成二进制,两条链合起来构成回文\(\rightarrow\)异或和为0或者只有一位是1 一开始困惑于只处理到当前根的异或和的话,随着当前…