Submission #691813

#TimeUsernameProblemLanguageResultExecution timeMemory
691813sunshine19Vlak (COCI20_vlak)C++14
70 / 70
17 ms13128 KiB
#include<iostream> #include<vector> #include<map> using namespace std; struct Node { int num = 0; 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]; } } bool traverse(Node* ni, Node* em, bool move, int d) { Node* ts[] = {em, ni}; if(ts[move]->next.empty()) return !move; 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, d+1) == 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, 0) ? "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...