# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
373252 |
2021-03-03T23:40:35 Z |
sam571128 |
Vlak (COCI20_vlak) |
C++14 |
|
2 ms |
1388 KB |
#include <bits/stdc++.h>
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int N = 2e3+5;
int tr[N][26], win[N], p[N][2], cnt = 0;
void insert(string &s, int player){
int now = 0;
for(auto c : s){
if(!tr[now][c-'a']) now = tr[now][c-'a'] = ++cnt;
else now = tr[now][c-'a'];
}
p[now][player] = 1;
}
void dfs(int now, int turn = 0){
bool has = 0, ok = 0;
for(int i = 0;i < 26;i++){
if(!tr[now][i]) continue;
dfs(tr[now][i]);
ok = 1;
if(!win[tr[now][i]]) has = 1;
}
if(!ok){
if(p[now][turn]) win[now] = 1;
}
if(has) win[now] = 1;
}
signed main(){
fastio
int n;
cin >> n;
for(int i = 0;i < n;i++){
string s;
cin >> s;
insert(s,0);
}
int m;
cin >> m;
for(int i = 0;i < m;i++){
string s;
cin >> s;
insert(s,1);
}
dfs(0);
cout << (win[0] ? "Nina" : "Emilija") << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
620 KB |
Output is correct |
2 |
Correct |
1 ms |
620 KB |
Output is correct |
3 |
Incorrect |
1 ms |
620 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
620 KB |
Output is correct |
2 |
Correct |
1 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
620 KB |
Output is correct |
4 |
Incorrect |
1 ms |
620 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
620 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
620 KB |
Output is correct |
2 |
Correct |
1 ms |
620 KB |
Output is correct |
3 |
Correct |
1 ms |
620 KB |
Output is correct |
4 |
Correct |
1 ms |
620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1388 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1388 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1388 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |