Submission #405681

#TimeUsernameProblemLanguageResultExecution timeMemory
405681souvenir_vayneVlak (COCI20_vlak)C++14
70 / 70
25 ms23244 KiB
#include<bits/stdc++.h> using namespace std; struct trie { trie *a[26]; bool can[26]; int sz = 0; }; trie *x = new trie(); bool dfs(trie *u) { bool ans = (u->sz) & 1; ans = !ans; for(int i = 0; i < 26; i++) { if(!(u->can[i])) continue; if( (u->sz & 1) ) { ans = max(ans, dfs(u->a[i])); if(ans) return 1; } else { ans = min(ans, dfs(u->a[i])); if(!ans) return 0; } } return ans; } int32_t main() { int n; cin >> n; while(n--) { string s; cin >> s; trie *aux = x; for(int i = 0; i < s.size(); i++) { if(aux->a[s[i] - 'a'] == NULL) aux->a[s[i] - 'a'] = new trie(); if(i%2 == 0) aux->can[s[i] - 'a'] = 1; aux = aux->a[s[i] - 'a']; aux->sz = i+1; } } cin >> n; while(n--) { string s; cin >> s; trie *aux = x; for(int i = 0; i < s.size(); i++) { if(aux->a[s[i] - 'a'] == NULL) aux->a[s[i] - 'a'] = new trie(); if(i & 1) aux->can[s[i] - 'a'] = 1; aux = aux->a[s[i] - 'a']; aux->sz = i+1; } } cout << (dfs(x) ? "Emilija" : "Nina") << endl; }

Compilation message (stderr)

Main.cpp: In function 'int32_t main()':
Main.cpp:46:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |         for(int i = 0; i < s.size(); i++) {
      |                        ~~^~~~~~~~~~
Main.cpp:65:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |         for(int i = 0; i < s.size(); i++) {
      |                        ~~^~~~~~~~~~
#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...