# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
881014 |
2023-11-30T10:50:26 Z |
TAhmed33 |
Vlak (COCI20_vlak) |
C++ |
|
14 ms |
42708 KB |
#include <bits/stdc++.h>
using namespace std;
int a[200001][26];
int b[200001][26];
int sze1 = 0, sze2 = 0;
void insert1 (string s) {
int cur = 0;
for (auto i : s) {
if (a[cur][i - 'a'] == -1) a[cur][i - 'a'] = ++sze1;
cur = a[cur][i - 'a'];
}
}
void insert2 (string s) {
int cur = 0;
for (auto i : s) {
if (b[cur][i - 'a'] == -1) b[cur][i - 'a'] = ++sze2;
cur = b[cur][i - 'a'];
}
}
int dp[200001][2];
int ans (int x, int y, int c) {
int &ret = dp[x][c];
if (ret != -1) return ret;
ret = 0;
if (!c) {
for (int i = 0; i < 26; i++) {
if (a[x][i] != -1 && b[y][i] == -1) {
ret = 1;
} else if (a[x][i] != -1) {
ret |= !ans(a[x][i], b[y][i], 1);
}
}
} else {
for (int i = 0; i < 26; i++) {
if (b[y][i] != -1 && a[x][i] == -1) {
ret = 1;
} else if (b[y][i] != -1) {
ret |= !ans(a[x][i], b[y][i], 0);
}
}
}
return ret;
}
int main () {
memset(a, -1, sizeof(a));
memset(b, -1, sizeof(b));
memset(dp, -1, sizeof(dp));
int n;
cin >> n;
while (n--) {
string s;
cin >> s;
insert1(s);
}
cin >> n;
while (n--) {
string s;
cin >> s;
insert2(s);
}
cout << (ans(0, 0, 0) ? "Nina" : "Emilijia") << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
42588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
42708 KB |
Output is correct |
2 |
Correct |
6 ms |
42584 KB |
Output is correct |
3 |
Correct |
6 ms |
42588 KB |
Output is correct |
4 |
Incorrect |
6 ms |
42588 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
42588 KB |
Output is correct |
2 |
Correct |
6 ms |
42588 KB |
Output is correct |
3 |
Incorrect |
6 ms |
42588 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
42588 KB |
Output is correct |
2 |
Correct |
6 ms |
42588 KB |
Output is correct |
3 |
Correct |
6 ms |
42480 KB |
Output is correct |
4 |
Incorrect |
6 ms |
42588 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
42588 KB |
Output is correct |
2 |
Incorrect |
13 ms |
42588 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
42588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
11 ms |
42584 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |