| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 550933 | Jomnoi | Vlak (COCI20_vlak) | C++17 | 32 ms | 22612 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>
#define DEBUG false
using namespace std;
class Node {
public :
Node *c[26];
bool finish;
Node() : finish(false) {
for(int i = 0; i < 26; i++) {
c[i] = NULL;
}
}
};
void add(Node *node, string s, int idx) {
if(idx == s.length()) {
node->finish = true;
return;
}
int v = s[idx] - 'a';
if(node->c[v] == NULL) {
node->c[v] = new Node();
}
add(node->c[v], s, idx + 1);
}
bool solve(Node *node1, Node *node2, bool turn) {
bool ok;
if(turn == true) { // Nina
if(node1 == NULL) {
return false;
}
ok = false;
for(int i = 0; i < 26; i++) {
if(node1->c[i] != NULL) {
ok |= solve(node1->c[i], node2->c[i], turn ^ true);
}
}
}
else { // Emilija
if(node2 == NULL) {
return true;
}
ok = true;
for(int i = 0; i < 26; i++) {
if(node2->c[i] != NULL) {
ok &= solve(node1->c[i], node2->c[i], turn ^ true);
}
}
}
return ok;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int n;
cin >> n;
Node *root1 = new Node();
for(int i = 1; i <= n; i++) {
string s;
cin >> s;
add(root1, s, 0);
}
int m;
cin >> m;
Node *root2 = new Node();
for(int i = 1; i <= m; i++) {
string s;
cin >> s;
add(root2, s, 0);
}
if(solve(root1, root2, true) == true) {
cout << "Nina";
}
else {
cout << "Emilija";
}
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... | ||||
