제출 #1122839

#제출 시각아이디문제언어결과실행 시간메모리
1122839courte_.sanmaVlak (COCI20_vlak)C++20
10 / 70
20 ms21648 KiB
#include<bits/stdc++.h> using namespace std; int n,m; struct trie { trie* child[26]; int turn,type[2],val,eow; trie() { for (int i=0; i<26; ++i) child[i]=NULL; turn=type[0]=type[1]=val=eow=0; } }; trie* root=new trie(); void add(string s, int type) { trie* cur=root; for (char c:s) { if (cur->child[c-'a']==NULL) { cur->child[c-'a']=new trie(); } cur->child[c-'a']->turn=(cur->turn+1)%2; cur->child[c-'a']->type[type]=1; cur=cur->child[c-'a']; } cur->eow=1; } void calc(trie* cur) { if (cur->val) return; if (!cur->type[cur->turn]) { cur->val=0; return; } if (cur->eow) { cur->val=1; return; } for (int i=0; i<26; ++i) { if (cur->child[i]==NULL) continue; calc(cur->child[i]); if (cur->child[i]->val==0) cur->val=1; } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n; for (int i=1; i<=n; ++i) { string s; cin>>s; add(s,1); } cin>>m; for (int i=1; i<=m; ++i) { string s; cin>>s; add(s,0); } root->type[0]=1; calc(root); if (root->val==1) cout<<"Nina"; else cout<<"Emilija"; return 0; }
#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...