Submission #3311830


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 1541 Byte
Status CE

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:20:10: error: reference to ‘hash’ is ambiguous
   has[i]=hash(name[i]);
          ^
./Main.cpp:9:20: note: candidates are: long long unsigned int hash(char*)
 unsigned long long hash(char* x){
                    ^
In file included from /usr/include/c++/5/bits/basic_string.h:5556:0,
                 from /usr/include/c++/5/string:52,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/istream:38,
                 from /usr/include/c++/5/sstream:38,
                 from /usr/include/c++/5/complex:45,
                 from /usr/include/c++/5/ccomplex:38,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:52,
                 from ./Main.cpp:1:
/usr/include/c++/5/bits/functional_hash.h:58:12: note:                 template<class _Tp> struct std::hash
     struct hash;
         ...