摘要:对于2-n每个点记录向左向右走完接下来要走的路长为什么可以搜?因为只变化第一个而每次又从第一个走,那我们显然只需要记录每个点向左向右两种值要记得每次搜索都要初始1节点向右为没走过== 1 #include 2 #include 3 #include 4 using namespace std; 5 ...
阅读全文
摘要:n,LL>mp迭代是(it->first).first== 又学了一点stl 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 #define LL long long 7 pairtmp; 8 map,LL>m...
阅读全文
摘要:关键点在于,什么时候需要改变?注意到只有一个2*2的矩形里面只有一个星才需要改变这个星为点只要想到这个这题就能各种姿势搜索了===可以dfs,从可变矩形向四周拓展== 1 #include 2 #include 3 #include 4 using namespace std; 5 int xx[]...
阅读全文
摘要:其实就两个方向,不符合就改嘛所以从任意一个点开始,两个方向更改的最小值就是答案== 1 #include 2 #include 3 #include 4 using namespace std; 5 int n,vis[1005]; 6 struct dian{ 7 int num1,num2,...
阅读全文
摘要:同:http://www.cnblogs.com/xiao-xin/articles/4196009.html顺手也给做了,更简单了一些== 1 #include 2 #include 3 #include 4 using namespace std; 5 #define LL long long ...
阅读全文
摘要:算出每个边被选中概率,然后每条边权×概率,和即为答案。一共有C(n,3)种选法,每条边下边有down[x]个,上面有n-down[x]个,选取该边方法有down[x]*(n-down[x])*(n-2) thinking==然后初以总选法就是概率。 1 #include 2 #include 3 #...
阅读全文
摘要:注意到,只要在搜索过程中出现一种颜色大于剩下格子/2,必然不用继续向下搜索。 1 #include 2 #include 3 #include 4 using namespace std; 5 int d[105][105],c[105]; 6 int n,m,k,temp; 7 int judge...
阅读全文
摘要:1 #include 2 #include 3 int hash[25],map[25][5],m,k,jilu[25]; 4 void dfs(int now,int step) 5 { 6 int i,judge; 7 jilu[step]=now; 8 if (ste...
阅读全文
摘要:1 #include 2 #include 3 int n,m,min,father[15],map[15][15]; 4 int find(int i) 5 { 6 if (father[i]!=i) return(find(father[i])); 7 return(fathe...
阅读全文
摘要:1 #include 2 #include 3 int xx[]={0,0,1,-1}; 4 int yy[]={1,-1,0,0}; 5 int used[15][15]; 6 char map[15][15]; 7 int n,m,t,x2,y2; 8 typedef struct dian ...
阅读全文