Submission #972756

#TimeUsernameProblemLanguageResultExecution timeMemory
97275612345678Vlak (COCI20_vlak)C++17
70 / 70
14 ms22696 KiB
#include <bits/stdc++.h> using namespace std; int n, m; string s; struct node { int w; node* p[26]; node() { w=0; for (int i=0; i<26; i++) p[i]=0; } }; typedef node* pnode; pnode rt1=new node(), rt2=new node(); void build(pnode &k, int idx, int sz) { if (idx==sz) return; if (!(k->p[s[idx]-'a'])) k->p[s[idx]-'a']=new node(); build(k->p[s[idx]-'a'], idx+1, sz); } void solve(pnode l, pnode r) { for (int i=0; i<26; i++) if (l->p[i]&&!(r->p[i])) return l->w=1, void(); for (int i=0; i<26; i++) if (l->p[i]) solve(r->p[i], l->p[i]), l->w|=!(r->p[i]->w); } int main() { cin.tie(NULL)->sync_with_stdio(false); cin>>n; for (int i=0; i<n; i++) cin>>s, build(rt1, 0, s.size()); cin>>m; for (int i=0; i<m; i++) cin>>s, build(rt2, 0, s.size()); solve(rt1, rt2); if (rt1->w) cout<<"Nina"; else cout<<"Emilija"; }
#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...