# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
986271 |
2024-05-20T07:44:01 Z |
SoSmolSten |
Vlak (COCI20_vlak) |
C++17 |
|
12 ms |
23900 KB |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 2e5 + 10;
string s[N], t[N];
struct Trie{
Trie* next[26];
int cnt;
Trie(){
cnt = 0;
for(int i = 0; i < 26; ++i) next[i] = NULL;
}
}* root;
void insert(string&, int);
bool traverse(string&, int);
int main (int argc, char const *argv[]) {
ios_base::sync_with_stdio(0);
cin.tie(0);
root = new Trie();
int n; cin >> n;
for(int i = 1; i <= n; ++i) cin >> s[i];
int m; cin >> m;
for(int i = 1; i <= n; ++i) {
cin >> t[i];
insert(t[i], t[i].length());
}
for(int i = 1; i <= n; ++i){
if(traverse(s[i], s[i].length())){
cout << "Nina";
return 0;
}
}
cout << "Emilija";
return 0;
}
void insert(string& str, int n){
Trie* node = root;
for(int i = 0; i < n; ++i){
int c = str[i] - 'a';
if(node->next[c] == NULL) node->next[c] = new Trie();
node = node->next[c];
++node->cnt;
}
}
bool traverse(string& str, int n){
Trie* node = root;
int cnt = -1;
for(int i = 0; i < n; ++i){
int c = str[i] - 'a';
if(node->next[c] == NULL) {
return !(i & 1);
}
node = node->next[c];
if(i != 0){
if(cnt != node->cnt) {
if(!(i & 1)) return 0;
}
}
cnt = node->cnt;
}
return n & 1;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
12892 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
12892 KB |
Output is correct |
2 |
Correct |
3 ms |
12892 KB |
Output is correct |
3 |
Correct |
3 ms |
12892 KB |
Output is correct |
4 |
Incorrect |
3 ms |
12892 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
12892 KB |
Output is correct |
2 |
Correct |
3 ms |
12892 KB |
Output is correct |
3 |
Incorrect |
3 ms |
12892 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
12892 KB |
Output is correct |
2 |
Correct |
3 ms |
12892 KB |
Output is correct |
3 |
Correct |
3 ms |
12892 KB |
Output is correct |
4 |
Incorrect |
3 ms |
12948 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
23896 KB |
Output is correct |
2 |
Incorrect |
11 ms |
23132 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
10 ms |
23900 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
23388 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |