# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
515686 | 2022-01-19T13:14:29 Z | mhsi2005 | Vlak (COCI20_vlak) | C++17 | 70 ms | 85948 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e5 + 10; ll n, m, trie[maxn][30][4], nodes = 1; void add (string &s, int a) { int v = 0; for(int i = 0; i < s.size(); i++) { if (!trie[v][s[i] - 'a'][0]) trie[v][s[i] - 'a'][0] = nodes++; trie[v][s[i] - 'a'][a] = 1; v = trie[v][s[i] - 'a'][0]; } } int winner (int v, int a) { bool res = false; for (int x = 0; x < 27; x++) { if (!trie[v][x][a]) continue; if (!trie[v][x][3 - a]) res = true; else res |= (winner(trie[v][x][0], 3 - a) == a); } return (res ? a : 3 - a); } int main() { cin >> n; for (int i = 0; i < n; i++) { string s; cin >> s; add(s, 1); } cin >> m; for (int i = 0; i < m; i++) { string s; cin >> s; add(s, 2); } cout << (winner(0, 1) == 1 ? "Nina\n" : "Emilija\n"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1304 KB | Output is correct |
2 | Correct | 1 ms | 1484 KB | Output is correct |
3 | Correct | 2 ms | 1356 KB | Output is correct |
4 | Correct | 1 ms | 1196 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1484 KB | Output is correct |
2 | Correct | 1 ms | 1356 KB | Output is correct |
3 | Correct | 1 ms | 1356 KB | Output is correct |
4 | Correct | 1 ms | 1356 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1100 KB | Output is correct |
2 | Correct | 1 ms | 1336 KB | Output is correct |
3 | Correct | 1 ms | 1196 KB | Output is correct |
4 | Correct | 1 ms | 1228 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1100 KB | Output is correct |
2 | Correct | 1 ms | 1228 KB | Output is correct |
3 | Correct | 1 ms | 1228 KB | Output is correct |
4 | Correct | 1 ms | 1200 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 56 ms | 80356 KB | Output is correct |
2 | Correct | 56 ms | 75244 KB | Output is correct |
3 | Correct | 50 ms | 70896 KB | Output is correct |
4 | Correct | 57 ms | 78384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 68 ms | 82208 KB | Output is correct |
2 | Correct | 59 ms | 85948 KB | Output is correct |
3 | Correct | 53 ms | 78936 KB | Output is correct |
4 | Correct | 56 ms | 80300 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 58 ms | 77648 KB | Output is correct |
2 | Correct | 54 ms | 75584 KB | Output is correct |
3 | Correct | 66 ms | 77624 KB | Output is correct |
4 | Correct | 70 ms | 82536 KB | Output is correct |