Submission #965333

#TimeUsernameProblemLanguageResultExecution timeMemory
965333noyancanturkVlak (COCI20_vlak)C++17
70 / 70
17 ms19804 KiB
#include "bits/stdc++.h" using namespace std; #define int int64_t #define pb push_back const int lim=1e6+100; const int mod=1e9+7; using pii=pair<int,int>; int sum(int i,int j){ if(i+j<mod)return i+j; return i+j-mod; } struct trie{ struct node{ int c[26]; bool dude[2]; }; node nds[lim]; int nextunused=2; void insert(const string&s,bool curdude){ int cur=1; int i=0; while(i<s.size()){ if(nds[cur].c[s[i]-'a']==0){ nds[cur].c[s[i]-'a']=nextunused++; } cur=nds[cur].c[s[i++]-'a']; } nds[cur].dude[curdude]=1; } struct iterator{ trie*par; int cur; iterator(trie*par,int b):par(par),cur(b){} node* operator()(){ return par->nds+cur; } void operator+=(char cc){ cur=par->nds[cur].c[cc-'a']; } bool operator==(const iterator&it){ return par==it.par&&cur==it.cur; } }; const iterator begin() { return iterator(this,1); }; const iterator end(){ return iterator(this,0); } bool retwin(node*p,bool turn){ bool have=0; int children=0; for(int i=0;i<26;i++){ if(p->c[i]){ children++; if(retwin(nds+p->c[i],!turn)==turn){ have=1; } p->dude[0]|=nds[p->c[i]].dude[0]; p->dude[1]|=nds[p->c[i]].dude[1]; } } if(p->dude[turn]&&have)return turn; return !turn; } bool retwin(){ return retwin(nds+1,0); } }tr; signed main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #ifdef Local freopen(".in","r",stdin); freopen(".out","w",stdout); #endif int n; cin>>n; for(int i=0;i<n;i++){ string s; cin>>s; tr.insert(s,0); } int m; cin>>m; for(int i=0;i<m;i++){ string s; cin>>s; tr.insert(s,1); } bool res=tr.retwin(); if(res)cout<<"Emilija\n"; else cout<<"Nina\n"; }

Compilation message (stderr)

Main.cpp: In member function 'void trie::insert(const string&, bool)':
Main.cpp:29:16: warning: comparison of integer expressions of different signedness: 'int64_t' {aka 'long int'} and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |         while(i<s.size()){
      |               ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...