首页 > TAG信息列表 > Mehrdad

「题解」Codeforces 741C Arpa’s overnight party and Mehrdad’s silent entering

直接无脑随机调整! 大力钦点 \(121212\cdots\) 分配。 有限制的之间记录一下,强制改成相反的,此后其中一个改变另一个也要改变。 这个时候可能不满足相邻三个不能都相同了,把冲突的拉到一个队列里面,每次取出队头随机钦点一个修改,再把修改后新产生的冲突拉到队列里面去。 复杂度玄学,实

#CodeForces CF741C Arpa’s overnight party and Mehrdad’s silent entering —— 二部图问题(构造、染色)

原题: Arpa loves overnight parties. In the middle of one of these parties Mehrdad suddenly appeared. He saw n pairs of friends sitting around a table. i-th pair consisted of a boy, sitting on the ai-th chair, and his girlfriend, sitting on the bi-th chair

CF741C Arpa’s overnight party and Mehrdad’s silent entering

Link 显然是二分图染色,情侣之间不同色直接一条边就行了。 而要连续的三个人不全同色,可以要求\((2i-1,2i)\)这两人不同色,这样一定满足连续的三人不全同色。 冷静分析发现这张图显然没有奇环,所以一定有解。 #include<cstdio> #include<cctype> #include<vector> #include<utility>

CF741B Arpa's weak amphitheater and Mehrdad's valuable Hoses

洛谷题址 看完这道题,我们看见后面句对于一个朋友圈,要么选其中一个,要么全选,就很容易想到是分组背包,那么接下来考虑的就是 怎么转化成分组背包的形式 显然我们用并查集可以维护出每个朋友圈,那么对于每个朋友圈我们开一个vector维护朋友圈中的人,同时把所有人也当做一个人,加

[cf741C]Arpa’s overnight party and Mehrdad’s silent entering

直接令2i-1和2i的位置不相同,相当于有2n条边,对其进行二分图染色即可(这张图一定不存在奇环)。 假设给出的n条关系是A类边,2i-1和2i的边是B类边,可以发现一条路径一定是AB交替(因为A/B的终点一定不可能是A/B的起点),那么环就一定是有等量的A边和B边,即偶环。 1 #include<bits/stdc++.h> 2

Codeforces 741 D - Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths

D - Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths 思路: 树上启发式合并 从根节点出发到每个位置的每个字符的奇偶性记为每个位置的状态,每次统计一下每个状态的最大深度 为了保证链经过当前节点u,我们先计算每个子树的答案,再更新子树状态对深度的贡献。 代码: #pra