摘要:#include using namespace std;#include int Min(int a,int b){ int c=a>str1) { int len=strlen(str1); if (len==0) continue; str[0]='$'; str[1] = '#'; int i , j = 2; for (i=0;ii) { p[i]=Min(p[2*id-i],mx-i); //优化的关键 ...
阅读全文
摘要:Problem Description很多学校流行一种比较的习惯。老师们很喜欢询问,从某某到某某当中,分数最高的是多少。这让很多学生很反感。不管你喜不喜欢,现在需要你做的是,就是按照老师的要求,写一个程序,模拟老师的询问。当然,老师有时候需要更新某位同学的成绩。 Input本题目包含多组测试,请处理到文件结束。#include using namespace std;const int maxn=200010;int max(int a,int b){ int c=a>b?a:b; return c;}struct Node { int left; int right;...
阅读全文
摘要:Problem DescriptionC国的死对头A国这段时间正在进行军事演习,所以C国间谍头子Derek和他手下Tidy又开始忙乎了。A国在海岸线沿直线布置了N个工兵营地,Derek和Tidy的任务就是要监视这些工兵营地的活动情况。由于采取了某种先进的监测手段,所以每个工兵营地的人数C国都掌握的一清二楚,每个工兵营地的人数都有可能发生变动,可能增加或减少若干人手,但这些都逃不过C国的监视。中央情报局要研究敌人究竟演习什么战术,所以Tidy要随时向Derek汇报某一段连续的工兵营地一共有多少人,例如Derek问:“Tidy,马上汇报第3个营地到第10个营地共有多少人!”Tidy就要马上开始计算
阅读全文
摘要:Problem DescriptionGiven a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let’s say the phone catalogue listed these numbers:1. Emergency 9112. Alice 97 625 9993. Bob 91 12 54 26In this case, it’s not possible to call Bob, because the centr
阅读全文
摘要:#include using namespace std;#include const int maxn=26;struct node { node *next[maxn]; int step;};void Create(node *T,char *str){ int len=strlen(str); for (int i=0;inext [id]==NULL) { node *p=(node *)malloc(sizeof(node)); p->step =1; for (int j=0;...
阅读全文
摘要:Problem Description某省调查城镇交通状况,得到现有城镇道路统计表,表中列出了每条道路直接连通的城镇。省政府“畅通工程”的目标是使全省任何两个城镇间都可以实现交通(但不一定有直接的道路相连,只要互相间接通过道路可达即可)。问最少还需要建设多少条道路?Input测试输入包含若干测试用例。每个测试用例的第1行给出两个正整数,分别是城镇数目N ( using namespace std;const int maxn=1010;int fat[maxn];int Find(int x){ if (fat[x]!=x) fat[x]=Find(fat[x]); ...
阅读全文
摘要:Problem Description某省调查乡村交通状况,得到的统计表中列出了任意两村庄间的距离。省政府“畅通工程”的目标是使全省任何两个村庄间都可以实现公路交通(但不一定有直接的公路相连,只要能间接通过公路可达即可),并要求铺设的公路总长度为最小。请计算最小的公路总长度。Input测试输入包含若干测试用例。每个测试用例的第1行给出村庄数目N ( using namespace std;const int maxn=110;int map[maxn][maxn];int dis[maxn];int used[maxn];const int INF=0x3fffffff;void prim(i
阅读全文
摘要:Problem Description有N个比赛队(1using namespace std;#include #include const maxn=550;int map[maxn][maxn];int in[maxn];int used[maxn];queue Q;void topol(int N,int M){ memset(map,0,sizeof(map)); memset(in,0,sizeof(in)); memset(used,0,sizeof(used)); int i,j; int a,b; int t; for (i=1;i>a...
阅读全文
摘要:Problem Description在每年的校赛里,所有进入决赛的同学都会获得一件很漂亮的t-shirt。但是每当我们的工作人员把上百件的衣服从商店运回到赛场的时候,却是非常累的!所以现在他们想要寻找最短的从商店到赛场的路线,你可以帮助他们吗?Input输入包括多组数据。每组数据第一行是两个整数N、M(Nusing namespace std;#include int map[110][110];int used[110];int dis[110];int main(){ int N,M; int A,B,C; while (cin>>N>>M,N &&
阅读全文
摘要:#include #include #include using namespace std;struct node { int x,y; int step; //保存拐弯数}s,e;char map[110][110];int used[110][110];int Point[4][2]={1,0 ,-1,0 ,0,1 ,0,-1 };int bx,by,ex,ey,k,n,m;queue Q;int is_ok(int x,int y){ if (x>=1 && x=1 && y<=m && map[x][y]=='.
阅读全文
摘要:Oil DepositsTime Limit : 2000/1000ms (Java/Other)Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 41Accepted Submission(s) : 17Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem DescriptionThe GeoSurvComp geologic survey company is responsible for detecting underground oil d
阅读全文
摘要:#include #include using namespace std;int main(){ queue qa; queue qb; int T,N; int a; int lena,lenb; while (cin>>T) { while (T--) { cin>>N; for (int i=1;i<=N;i++) { qa.push (i); } if (qa.size ()<...
阅读全文