제출 #1122843

#제출 시각아이디문제언어결과실행 시간메모리
1122843courte_.sanmaVlak (COCI20_vlak)C++17
20 / 70
21 ms21576 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=0; type[0]=0; type[1]=0; eow=0; val=-1; } }; 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; cur->child[c-'a']->type[type]=1; cur=cur->child[c-'a']; } cur->eow=1; } int calc(trie* cur) { if (cur->val!=-1) return cur->val; if (!cur->type[cur->turn]) return cur->val=0; // if (cur->eow) return cur->val=1; cur->val=0; for (int i=0; i<26; ++i) { if (cur->child[i]==NULL) continue; if (calc(cur->child[i])==0) cur->val=1; } return cur->val; } 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; if (calc(root)==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...