Submission #550933

#TimeUsernameProblemLanguageResultExecution timeMemory
550933JomnoiVlak (COCI20_vlak)C++17
70 / 70
32 ms22612 KiB
#include <bits/stdc++.h> #define DEBUG false using namespace std; class Node { public : Node *c[26]; bool finish; Node() : finish(false) { for(int i = 0; i < 26; i++) { c[i] = NULL; } } }; void add(Node *node, string s, int idx) { if(idx == s.length()) { node->finish = true; return; } int v = s[idx] - 'a'; if(node->c[v] == NULL) { node->c[v] = new Node(); } add(node->c[v], s, idx + 1); } bool solve(Node *node1, Node *node2, bool turn) { bool ok; if(turn == true) { // Nina if(node1 == NULL) { return false; } ok = false; for(int i = 0; i < 26; i++) { if(node1->c[i] != NULL) { ok |= solve(node1->c[i], node2->c[i], turn ^ true); } } } else { // Emilija if(node2 == NULL) { return true; } ok = true; for(int i = 0; i < 26; i++) { if(node2->c[i] != NULL) { ok &= solve(node1->c[i], node2->c[i], turn ^ true); } } } return ok; } int main() { cin.tie(nullptr)->sync_with_stdio(false); int n; cin >> n; Node *root1 = new Node(); for(int i = 1; i <= n; i++) { string s; cin >> s; add(root1, s, 0); } int m; cin >> m; Node *root2 = new Node(); for(int i = 1; i <= m; i++) { string s; cin >> s; add(root2, s, 0); } if(solve(root1, root2, true) == true) { cout << "Nina"; } else { cout << "Emilija"; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'void add(Node*, std::string, int)':
Main.cpp:17:9: 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(idx == s.length()) {
      |     ~~~~^~~~~~~~~~~~~
#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...