Those are not the droids you're looking for 题目连接: http://acm.timus.ru/problem.aspx?space=1&num=1997 Description Bar owner: Hey. We don't serve their kind here. Luke: What? Bar owner: Your droids – they'll have to wait outside. We don't want them here…
二分图的最大匹配. 每一个$0$与$1$配对,只建立满足时差大于等于$a$或者小于等于$b$的边,如果二分图最大匹配等于$n/2$,那么有解,遍历每一条边输出答案,否则无解. #include<map> #include<set> #include<ctime> #include<cmath> #include<queue> #include<string> #include<vector> #include<cst…
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1997 这个星球上有两种人,一种进酒吧至少玩a小时,另一种进酒吧最多玩b小时. 下面n行是人进进出出的时刻,0为进,1为出.让你求是否有合法解. 将合法的进入和出去连边,然后二分匹配就可以了. #include <iostream> #include <cstring> #include <cstdio> #include <vector> #inc…
1011. Conductors Time limit: 2.0 secondMemory limit: 64 MB Background Everyone making translations from English to Russian knows an English phrase "Naked conductor runs along the bus". It has two very different meanings. Problem Every bus in the…
一条边<u,v>表示u选那么v一定被选. #include <iostream> #include <cstring> #include <cstdio> #include <algorithm> using namespace std; ; ; struct EDGE{int to,next;}edge[Maxm]; int T,m,Stack[Maxn],head[Maxn],Belong[Maxn],Id[Maxn],Dfn[Maxn],L…
题目:http://www.lydsy.com:808/JudgeOnline/problem.php?id=1997 分析: 考虑每条边是在圈子里面还是圈子外面 所以就变成了2-SAT判定问题了= =,于是求SCC,如果一个点对应的2个bool点在一个SCC中就无解了. 当然这样建图好像要TLE…… 然后就要上大杀器了:平面图|E|<=3|V|-6 所以,如果m>3n-6就直接输出NO了…
题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串中心位置,RMQ询问LCP = min (height[rank[l]+1] to height[rank[r]]),注意的是RMQ传入参数最好是后缀的位置,因为它们在树上的顺序未知,且左边还要+1. #include <cstdio> #include <algorithm> #in…
2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and each orders a juice cocktail. It could be from 1 to 3 different juices in each cocktail. There are three juices in the bar: apple, banana and pineappl…
2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best programmer in the world! Now he regularly takes part in various programming contests, attentively listens to problems analysis and upsolves problems. But…
2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate integers together in their spare time. Nikolay thinks an integer is interesting if it is a prime number. However, Asya thinks an integer is interesting i…