Submission #3311837


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];
char name[maxn][maxn],a[maxn],b[maxn];
bool onaji[maxn];
unsigned long long _hash(char* x){
    unsigned long long h=(unsigned long long)(x[0]-'0'+1);
    int d=strlen(x);
    for(int i=1;i<d;i++) h=(h*H+(unsigned long long)(x[i]-'0'+1))%mod;
    return h;
}
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];
		}
	}
	int temp;
	for(temp=1;temp<=n;temp++) if(iro[temp]==2) break;
	if(temp>n) for(register int i=1;i<=n;i++) printf("%s\n",name[i]);
	else for(register int i=1;i<=n;i++) if(iro[i]==1) printf("%s\n",name[i]);
	return 0;
}

Submission Info

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

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:16:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d",&n);
                ^
./Main.cpp:19:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
   scanf("%s",name[i]);
                      ^
./Main.cpp:25: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:26: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:31: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 × 20
WA × 7
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 WA 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