# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
388463 |
2021-04-11T15:50:28 Z |
phathnv |
Vlak (COCI20_vlak) |
C++11 |
|
24 ms |
21800 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct Node{
int state, cnt[2];
Node *child[26];
Node(){
state = 0;
cnt[0] = cnt[1] = 0;
for(int i = 0; i < 26; i++)
child[i] = nullptr;
}
};
struct Trie{
Node *root = new Node;
void add(const string &s, int type){
Node *cur = root;
for(char ch : s){
int nxt = ch - 'a';
if (cur->child[nxt] == nullptr)
cur->child[nxt] = new Node;
cur = cur->child[nxt];
cur->cnt[type]++;
}
}
bool solve(Node *cur, int turn){
cur->state = 0;
for(int i = 0; i < 26; i++){
if (cur->child[i] == nullptr)
continue;
if (cur->child[i]->cnt[turn] && !solve(cur->child[i], turn ^ 1))
cur->state = 1;
}
return cur->state;
}
bool solve(){
return solve(root, 0);
}
};
int m, n;
Trie trie;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cin >> m;
for(int i = 1; i <= m; i++){
string s;
cin >> s;
trie.add(s, 0);
}
cin >> n;
for(int i = 1; i <= n; i++){
string s;
cin >> s;
trie.add(s, 1);
}
cout << (trie.solve()? "Nina" : "Emilija");
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
588 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
568 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
440 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
460 KB |
Output is correct |
2 |
Correct |
1 ms |
460 KB |
Output is correct |
3 |
Correct |
1 ms |
460 KB |
Output is correct |
4 |
Correct |
1 ms |
460 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
23 ms |
20432 KB |
Output is correct |
2 |
Correct |
19 ms |
19188 KB |
Output is correct |
3 |
Correct |
17 ms |
18096 KB |
Output is correct |
4 |
Correct |
19 ms |
19912 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
16 ms |
20872 KB |
Output is correct |
2 |
Correct |
16 ms |
21800 KB |
Output is correct |
3 |
Correct |
16 ms |
20060 KB |
Output is correct |
4 |
Correct |
16 ms |
20428 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
20 ms |
19788 KB |
Output is correct |
2 |
Correct |
24 ms |
19296 KB |
Output is correct |
3 |
Correct |
17 ms |
19728 KB |
Output is correct |
4 |
Correct |
18 ms |
20940 KB |
Output is correct |