| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 474072 | mychecksedad | Vlak (COCI20_vlak) | C++17 | 90 ms | 169244 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
const int N = 1000000, F = 1e9;
struct Node{
int child[26];
short value, color;
Node(){
for(int i = 0; i < 26; i++) child[i] = -1;
value = color = 0;
}
};
int n, m, cur = 1;
Node trie[N];
string s[N], t[N];
bool dfs(int v, int d){
if(v == 0){
int ans = 0;
for(int i = 0; i < 26; i++) if(trie[v].child[i] != -1) ans |= dfs(trie[v].child[i], d+1);
return ans;
}
if(d & 1){
if(trie[v].color == 1){
return 1;
}else if(trie[v].color == 3){
return 1;
}else if(trie[v].value == 1){
return 1;
}else if(!(trie[v].value & 1)){
return 0;
}else{
bool ans = 0;
for(int i = 0; i < 26; i++){
if(trie[v].child[i] != -1) ans |= dfs(trie[v].child[i], d+1);
}
return ans;
}
}
if(trie[v].color == 2){
return 0;
}else if(trie[v].color == 3){
return 0;
}else if(trie[v].value == 2){
return 0;
}else if(!(trie[v].value & 2)){
return 1;
}else{
bool ans = 1;
for(int i = 0; i < 26; i++){
if(trie[v].child[i] != -1) ans &= dfs(trie[v].child[i], d+1);
}
return ans;
}
}
int main(){
cin.tie(0); ios::sync_with_stdio(0);
cin >> n;
for(int i = 0; i < n; i++){
cin >> s[i];
int v = 0;
for(int j = 0; j < s[i].length(); j++){
if(trie[v].child[s[i][j] - 'a'] == -1){
trie[v].child[s[i][j] - 'a'] = cur++;
}
v = trie[v].child[s[i][j] - 'a'];
trie[v].value += 1;
}
trie[v].color += 1;
}
cin >> m;
for(int i = 0; i < m; i++){
cin >> t[i];
int v = 0;
for(int j = 0; j < t[i].length(); j++){
if(trie[v].child[t[i][j] - 'a'] == -1){
trie[v].child[t[i][j] - 'a'] = cur++;
}
v = trie[v].child[t[i][j] - 'a'];
trie[v].value += 2;
}
trie[v].color += 2;
}
bool ans = dfs(0, 0);
if(ans == 0) cout << "Emilija";
else cout << "Nina";
return 0;
}Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
