Submission #544405

#TimeUsernameProblemLanguageResultExecution timeMemory
544405DragosC1Vlak (COCI20_vlak)C++17
0 / 70
20 ms12524 KiB
#include <iostream> #include <map> using namespace std; struct trie { int win; map<int, trie*> lit; trie() { lit.clear(); } }; trie *root1, *root2; string s; void add(int ind, trie *node) { if (ind == s.size()) return; int l = s[ind] - 'a'; if (node->lit[l] == NULL) node->lit[l] = new trie(); add(ind + 1, node->lit[l]); } bool sch(trie *node1, trie *node2, int ind) { if (ind % 2 == 0) { int rez = 0; for (auto it = node1->lit.begin(); it != node1->lit.end(); it++) if (node2->lit[it->first] == NULL) { rez = 1; break; } else { bool x = sch(node1->lit[it->first], node2->lit[it->first], ind + 1); rez |= (1 - x); } return rez; } else { int rez = 1; for (auto it = node2->lit.begin(); it != node2->lit.end(); it++) if (node1->lit[it->first] == NULL) { rez = 1; break; } else { bool x = sch(node1->lit[it->first], node2->lit[it->first], ind + 1); rez &= (1 - x); } if (node2->lit.size() == 0) return 0; return rez; } } int main() { int i, n, m; root1 = new trie(); root2 = new trie(); cin >> n; for (i = 1; i <= n; i++) { cin >> s; add(0, root1); } cin >> m; for (i = 1; i <= m; i++) { cin >> s; add(0, root2); } if (sch(root1, root2, 0)) cout << "Nina"; else cout << "Emilija"; return 0; }

Compilation message (stderr)

Main.cpp: In function 'void add(int, trie*)':
Main.cpp:17:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     if (ind == s.size())
      |         ~~~~^~~~~~~~~~~
#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...