# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1083525 | 2024-09-03T11:28:18 Z | HaciyevAlik | Vlak (COCI20_vlak) | C++14 | 21 ms | 27740 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define oo 1000000000000000 const int mx = 1e6 + 5; int trie[mx][26]; int last; int dp[mx]; vector<int> mark; void insert(string s,bool turn) { int cur = 0; for(int i = 0; i < s.size(); ++i) { if(!trie[cur][s[i]-'a']) { trie[cur][s[i]-'a'] = ++last; } cur = trie[cur][s[i]-'a']; } if(mark[cur] == -1) { mark[cur] = turn; } else { mark[cur] = (mark[cur] != turn ? 2 : mark[cur]); } } void dfs(int u,int lvl) { if(lvl % 2) { dp[u] = 1; } else { dp[u] = 2; } bool check = false; for(int i = 0; i < 26; ++i) { if(trie[u][i]) { dfs(trie[u][i],lvl + 1); check = 1; if(lvl%2) dp[u] = max(dp[u],dp[trie[u][i]]); else dp[u] = min(dp[u],dp[trie[u][i]]); } } if(!check) { if(mark[u] == 2) { if(lvl%2) dp[u] = 1; else dp[u] = 2; } else { dp[u] = mark[u] + 1; } } } signed main(){ ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); mark.assign(mx, -1); int n; cin >> n; for(int i = 1; i <= n; ++i) { string s; cin >> s; insert(s,0); } int m; cin >> m; for(int i = 1; i <= m; ++i) { string s; cin >> s; insert(s,1); } dfs(0,0); if(dp[0] == 1) { cout << "Nina"; } else { cout << "Emilija"; } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8536 KB | Output is correct |
2 | Correct | 4 ms | 8536 KB | Output is correct |
3 | Correct | 4 ms | 8540 KB | Output is correct |
4 | Correct | 4 ms | 8540 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8540 KB | Output is correct |
2 | Correct | 4 ms | 8536 KB | Output is correct |
3 | Correct | 4 ms | 8540 KB | Output is correct |
4 | Correct | 4 ms | 8300 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8284 KB | Output is correct |
2 | Correct | 4 ms | 8540 KB | Output is correct |
3 | Correct | 4 ms | 8288 KB | Output is correct |
4 | Correct | 4 ms | 8540 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 8280 KB | Output is correct |
2 | Correct | 3 ms | 8540 KB | Output is correct |
3 | Correct | 3 ms | 8540 KB | Output is correct |
4 | Correct | 3 ms | 8284 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 26496 KB | Output is correct |
2 | Correct | 21 ms | 25180 KB | Output is correct |
3 | Correct | 16 ms | 24160 KB | Output is correct |
4 | Correct | 17 ms | 25948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 26712 KB | Output is correct |
2 | Correct | 19 ms | 27740 KB | Output is correct |
3 | Correct | 18 ms | 25948 KB | Output is correct |
4 | Correct | 15 ms | 26460 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 17 ms | 25692 KB | Output is correct |
2 | Correct | 18 ms | 25180 KB | Output is correct |
3 | Correct | 16 ms | 25688 KB | Output is correct |
4 | Correct | 18 ms | 26968 KB | Output is correct |