摘要: Problem B: WarA war is being lead between two countries, A and B. As a loyal citizen of C, you decide to help your country’s espionage by attending the peace-talks taking place these days (incognito, of course). There are n people at the talks (not including you), but you do not know which person be 阅读全文
posted @ 2014-02-19 21:08 ~~Snail~~ 阅读(280) 评论(0) 推荐(0) 编辑
摘要: It's not a Bug, it's a Feature!It is a curious fact that consumers buying a new software product generally donotexpect the software to be bug-free. Can you imagine buying a car whose steering wheel only turns to the right? Or a CD-player that plays only CDs with country music on them? Probab 阅读全文
posted @ 2014-02-19 18:10 ~~Snail~~ 阅读(470) 评论(0) 推荐(0) 编辑
摘要: 1 #define MAX_N 10000 2 3 int par[MAX_N]; 4 5 //并查集初始化,初始化n个元素 6 void init(int n) 7 { 8 for(int i=0;i<n;i++) 9 par[i]=i;10 }11 12 //并查集查询操作,查询树的根13 int Find(int x)14 {15 if(par[x]==x)16 return x;17 return par[x]=Find(par[x]);18 }19 20 //并查集合并操作,合并x和y所属集合21 void Unite(... 阅读全文
posted @ 2014-02-19 08:42 ~~Snail~~ 阅读(168) 评论(0) 推荐(0) 编辑
摘要: Floyd-Warshall算法用于求任意两点间的最短路问题 1 #define MAX_V 100 2 3 int d[MAX_V][MAX_V]; //d[u][v]表示边e=(u,v)的权值(不存在时设为INF,不过d[i][i]=0) 4 int V; //顶点数 5 6 int Min(int a,int b) 7 { 8 return a<b?a:b; 9 }10 11 void floyd_warshall()12 {13 for(int k=0;k<V;k++)14 for(int i=0;i<V;i++)15... 阅读全文
posted @ 2014-02-19 08:33 ~~Snail~~ 阅读(139) 评论(0) 推荐(0) 编辑
摘要: Problem A: FrecklesIn an episode of the Dick Van Dyke show, little Richie connects the freckles on his Dad's back to form a picture of the Liberty Bell. Alas, one of the freckles turns out to be a scar, so his Ripley's engagement falls through.Consider Dick's back to be a plane with frec 阅读全文
posted @ 2014-02-19 08:23 ~~Snail~~ 阅读(281) 评论(0) 推荐(0) 编辑
摘要: Problem B: AudiophobiaConsider yourself lucky! Consider yourself lucky to be still breathing and having fun participating in this contest. But we apprehend that many of your descendants may not have this luxury. For, as you know, we are the dwellers of one of the most polluted cities on earth. Pollu 阅读全文
posted @ 2014-02-19 08:14 ~~Snail~~ 阅读(273) 评论(0) 推荐(0) 编辑