hdu 2094 (水,直接C方法)

2014-11-24 02:49:05 · 作者: · 浏览: 1


/*


本来要用并查集的,感觉是并查集的题,但是无限WA。。。。。

后来看网上才发现,如此的水,,,,

只要没有输过的人数==1,就可以输出Yes了,否则No


2013-04-23


*/

[cpp]
#include"stdio.h"
#include"string.h"
int main()
{
int n;
int ans;
int i,j,k;
int count[1001];
char map[1001][20];
char s1[1001],s2[20];
while(scanf("%d",&n)!=-1)
{
if(!n)break;

memset(count,0,sizeof(count));
k=0;
for(i=0;i {
scanf("%s%s",s1,s2);
for(j=0;j if(strcmp(s1,map[j])==0)break;

if(j==k)
{
strcpy(map[k],s1);
k++;
}

for(j=0;j if(strcmp(s2,map[j])==0)break;

if(j==k)
{
strcpy(map[k],s2);
k++;
}

count[j]=1;
}

ans=0;
for(i=0;i if(count[i]==0)ans++;

if(ans==1)printf("Yes\n");
else printf("No\n");
}
return 0;
}

#include"stdio.h"
#include"string.h"
int main()
{
int n;
int ans;
int i,j,k;
int count[1001];
char map[1001][20];
char s1[1001],s2[20];
while(scanf("%d",&n)!=-1)
{
if(!n)break;

memset(count,0,sizeof(count));
k=0;
for(i=0;i {
scanf("%s%s",s1,s2);
for(j=0;j if(strcmp(s1,map[j])==0)break;

if(j==k)
{
strcpy(map[k],s1);
k++;
}

for(j=0;j if(strcmp(s2,map[j])==0)break;

if(j==k)
{
strcpy(map[k],s2);
k++;
}

count[j]=1;
}

ans=0;
for(i=0;i if(count[i]==0)ans++;

if(ans==1)printf("Yes\n");
else printf("No\n");
}
return 0;
}