제출 #691310

#제출 시각아이디문제언어결과실행 시간메모리
691310sunshine19Vlak (COCI20_vlak)C++14
10 / 70
14 ms13040 KiB
#include<iostream> #include<vector> #include<map> using namespace std; struct Node { bool num = false; map<char, Node*> next; }; void add(Node* root, string s) { for(char c : s) { if(root->next.find(c) == root->next.end()) root->next[c] = new Node(); root = root->next[c]; } root->num = true; } bool traverse(Node* ni, Node* em, bool move) { if(ni->next.empty() && em->next.empty()) return move; if(ni->next.empty()) return false; else if(em->next.empty()) return true; Node* ts[] = {ni, em}; for(auto p : ts[move]->next) { if(ts[!move]->next.find(p.first) == ts[!move]->next.end()) return move; if(traverse(ni->next[p.first], em->next[p.first], !move) == move) return move; } return !move; } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); Node* nina = new Node(); Node* ema = new Node(); int n, m; string s; cin>>n; while(n--) { cin>>s; add(nina, s); } cin>>m; while(m--) { cin>>s; add(ema, s); } cout<<(traverse(nina, ema, true) ? "Nina" : "Emilija")<<endl; 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...