参考这个博客 #include<cstdio> #include<algorithm> #include<cstring> #include<map> #include<vector> typedef long long ll; using namespace std; map< pair<int,int> , pair<int,int> > mp; map< pair<int,int> ,…
Lizard Era: Beginning 折半之后搜就完事了, 直接存string字符串卡空间, 随便卡卡空间吧. #include<bits/stdc++.h> #define LL long long #define fi first #define se second #define mk make_pair #define PLL pair<LL, LL> #define PLI pair<LL, int> #define PII pair<int, i…
原题 有n(n<=2)个任务和三个人,每次任务给出每个人能得到的值,每次任务选两个人,使n个任务结束后三个人得到的值是一样的.输出每次要派哪两个人,如果不行输出Impossible. n<=25,3^25肯定不行,所以考虑折半3^(n/2).前一半我们得到a,b,c,后一半我们得到x,y,z,我们要得到a+x=b+y=c+z.将式子变形为a-b=y-x和b-c=z-y,所以用map记录a-b和b-c,以及对应的最大的a和状态(三进制表示).然后查找y-x和z-y是否存在,得到答案即可. #in…
一眼题...这个数据范围也太明显了吧... suma1==suma2 && sumb1==sumb2 && sumc1==sumc2 相当于suma1-sumb1==sumb2-suma2 && suma1-sumc1==sumc2-suma2 于是前一半O(3^(N/2))搜出所有情况的suma1-sumb1和suma1-sumc1,后一半搜出sumb2-suma2和sumc2-suma2,都丢到一个数组里作为两个关键字排序,在两个关键字都相同的一段里面找…
In the game Lizard Era: Beginning the protagonist will travel with three companions: Lynn, Meliana and Worrigan. Overall the game has nmandatory quests. To perform each of them, you need to take exactly two companions. The attitude of each of the com…
F. Lizard Era: Beginning Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/586/problem/F Description In the game Lizard Era: Beginning the protagonist will travel with three companions: Lynn, Meliana and Worrigan. Overall the…
D. Lizard Era: Beginning time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output In the game Lizard Era: Beginning the protagonist will travel with three companions: Lynn, Meliana and Worrigan. Ov…
折半搜索,先搜索一半的数字,记录第一个人的值,第二个人.第三个人和第一个人的差值,开个map哈希存一下,然后另一半搜完直接根据差值查找前一半的答案. 代码 #include<cstdio> #include<map> #define ll long long #define N 100 using namespace std; map<long long,int> ma,Ma; ]; int n,i,a[N],b[N],c[N],Ans,A1,A2,ans[N]; vo…
嘟嘟嘟 题面我是不会咕的(没有真香):有\(n(n \leqslant 25)\)个任务和三个人,每次任务给出每个人能得到的值,每次任务选两个人,使\(n\)个任务结束后三个人得到的值是一样的,且尽量大.输出每次要派哪两个人,如果不行输出\(Impossible\). 暴力是\(O(3 ^ {25})\),必定过不去,但是如果一半\(O(3 ^ {13})\)就刚好可以过了,因此想到折半搜索. 令搜到的前一半的结果为\(a, b, c\),后一半为\(x, y, z\),那么我们需要的是\(a…
Codeforces Round #297 (Div. 2)E. Anya and Cubes Time Limit: 2 Sec  Memory Limit: 512 MBSubmit: xxx  Solved: 2xx 题目连接 http://codeforces.com/contest/525/problem/E Description Anya loves to fold and stick. Today she decided to do just that. Anya has n c…