Submission #3312075


Source Code Expand

#include<bits/stdc++.h>
using namespace std;
const unsigned long long H=333333331,mod=192608173;
const int maxn=25;
unsigned long long has[maxn];
int n,kanojo[maxn],iro[maxn],cnt1,cnt2;
char name[maxn][maxn],a[maxn],b[maxn],dasu1[maxn][maxn],dasu2[maxn][maxn];
bool onaji[maxn];
unsigned long long _hash(char* x){
    unsigned long long h=(unsigned long long)(x[0]-'A'+1);
    int d=strlen(x);
    for(int i=1;i<d;i++) h=(h*H+(unsigned long long)(x[i]-'A'+1))%mod;
    return h;
}
bool cmp(char* a,char* b){
	return strcmp(a,b)<0;
}
int main(){
	scanf("%d",&n);
	for(register int i=1;i<=n;i++){
		getchar();
		scanf("%s",name[i]);
		has[i]=_hash(name[i]);
	}
	unsigned long long haa;
	for(register int i=1;i<=n;i++){
		getchar();
		scanf("%s",a);haa=_hash(a);
		scanf("%s%s%s",b,b,b);
		for(register int j=1;j<=n;j++) if(has[j]==haa){
			kanojo[i]=j;break;
		}
		if(b[0]=='g') onaji[i]=true;
		scanf("%s",a);
	}
	int p;
	for(register int i=1;i<=n;i++) if(!iro[i]){
		p=i;iro[i]=1;
		while(true){
			if(onaji[p]){
				if(iro[kanojo[p]]){
					if(iro[kanojo[p]]!=iro[p]){
						printf("No answers\n");return 0;
					}
					else break;
				}
				iro[kanojo[p]]=iro[p];
			}
			else{
				if(iro[kanojo[p]]){
					if(iro[kanojo[p]]==iro[p]){
						printf("No answers\n");return 0;
					}
					else break;
				}
				iro[kanojo[p]]=3-iro[p];
			}
			p=kanojo[p];
		}
	}
	char temp[maxn];
	for(register int i=1;i<=n;i++) if(iro[i]==1) strcpy(dasu1[cnt1++],name[i]);
	for(register int i=1;i<=n;i++) if(iro[i]==2) strcpy(dasu2[cnt2++],name[i]);
	for(register int i=0;i<cnt1;i++) for(register int j=i;j<cnt1;j++) if(!cmp(dasu1[i],dasu1[j])){
		strcpy(temp,dasu1[i]);strcpy(dasu1[i],dasu1[j]);strcpy(dasu1[j],temp);
	}
	for(register int i=0;i<cnt2;i++) for(register int j=i;j<cnt2;j++) if(!cmp(dasu2[i],dasu2[j])){
		strcpy(temp,dasu2[i]);strcpy(dasu2[i],dasu2[j]);strcpy(dasu2[j],temp);
	}
	if(cnt1>cnt2) for(register int i=0;i<cnt1;i++) printf("%s\n",dasu1[i]);
	else if(cnt1<cnt2) for(register int i=0;i<cnt2;i++) printf("%s\n",dasu2[i]);
	else if(strcmp(dasu1[0],dasu2[0])<0) for(register int i=0;i<cnt1;i++) printf("%s\n",dasu1[i]);
	else for(register int i=0;i<cnt2;i++) printf("%s\n",dasu2[i]);
	return 0;
}

Submission Info

Submission Time
Task C - 酒場の冒険者たち
User fbhou
Language C++14 (GCC 5.4.1)
Score 0
Code Size 2276 Byte
Status WA
Exec Time 1 ms
Memory 256 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:19:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
./Main.cpp:22:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",name[i]);
                      ^
./Main.cpp:28:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",a);haa=_hash(a);
                ^
./Main.cpp:29:24: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s%s%s",b,b,b);
                        ^
./Main.cpp:34:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",a);
                ^

Judge Result

Set Name All
Score / Max Score 0 / 100
Status
AC × 21
WA × 6
Set Name Test Cases
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 00_sample_03.txt, 01_max_00.txt, 01_max_01.txt, 05_corner_00.txt, 05_corner_01.txt, 05_corner_02.txt, 10_min_00.txt, 10_min_01.txt, 10_min_02.txt, 10_wrong_answer_00.txt, 20_max_00.txt, 20_max_01.txt, 20_max_02.txt, 90_random_00.txt, 90_random_01.txt, 90_random_02.txt, 90_random_03.txt, 90_random_04.txt, 90_random_05.txt, 90_random_06.txt, 90_random_07.txt, 90_random_08.txt, 90_random_09.txt, 99_medium_00.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 256 KB
00_sample_01.txt AC 1 ms 256 KB
00_sample_02.txt AC 1 ms 256 KB
00_sample_03.txt AC 1 ms 256 KB
01_max_00.txt AC 1 ms 256 KB
01_max_01.txt AC 1 ms 256 KB
05_corner_00.txt AC 1 ms 256 KB
05_corner_01.txt WA 1 ms 256 KB
05_corner_02.txt WA 1 ms 256 KB
10_min_00.txt AC 1 ms 256 KB
10_min_01.txt AC 1 ms 256 KB
10_min_02.txt AC 1 ms 256 KB
10_wrong_answer_00.txt WA 1 ms 256 KB
20_max_00.txt AC 1 ms 256 KB
20_max_01.txt AC 1 ms 256 KB
20_max_02.txt AC 1 ms 256 KB
90_random_00.txt AC 1 ms 256 KB
90_random_01.txt AC 1 ms 256 KB
90_random_02.txt AC 1 ms 256 KB
90_random_03.txt AC 1 ms 256 KB
90_random_04.txt WA 1 ms 256 KB
90_random_05.txt WA 1 ms 256 KB
90_random_06.txt AC 1 ms 256 KB
90_random_07.txt AC 1 ms 256 KB
90_random_08.txt AC 1 ms 256 KB
90_random_09.txt AC 1 ms 256 KB
99_medium_00.txt WA 1 ms 256 KB