Submission #1084764

#TimeUsernameProblemLanguageResultExecution timeMemory
1084764Hamed5001Vlak (COCI20_vlak)C++14
70 / 70
12 ms21000 KiB
#include <bits/stdc++.h> using namespace std; const int mxM = 2e5 + 1; int trie[mxM][26][2], last; void insert(string const &s, int which) { int v = 0; for (char ch : s) { int c = ch - 'a'; if (!trie[v][c][which]) trie[v][c][which] = ++last; v = trie[v][c][which]; } } bool dfs(array<int, 2> v, int which) { bool ret = 0; for (int i = 0; i < 26; ++i) { if (trie[v[which]][i][which]) { if (!trie[v[1-which]][i][1-which]) { return 1; } ret |= !dfs({trie[v[0]][i][0], trie[v[1]][i][1]}, 1 - which); } } return ret; } int main() { cin.tie(0)->sync_with_stdio(false); int N; cin >> N; for (int i = 0; i < N; ++i) { string s; cin >> s; insert(s, 0); } cin >> N; for (int i = 0; i < N; ++i) { string s; cin >> s; insert(s, 1); } cout << (dfs({0, 0}, 0) ? "Nina" : "Emilija"); 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...