# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
405681 | souvenir_vayne | Vlak (COCI20_vlak) | C++14 | 25 ms | 23244 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
struct trie {
trie *a[26];
bool can[26];
int sz = 0;
};
trie *x = new trie();
bool dfs(trie *u) {
bool ans = (u->sz) & 1;
ans = !ans;
for(int i = 0; i < 26; i++) {
if(!(u->can[i])) continue;
if( (u->sz & 1) ) {
ans = max(ans, dfs(u->a[i]));
if(ans)
return 1;
}
else {
ans = min(ans, dfs(u->a[i]));
if(!ans)
return 0;
}
}
return ans;
}
int32_t main() {
int n;
cin >> n;
while(n--) {
string s;
cin >> s;
trie *aux = x;
for(int i = 0; i < s.size(); i++) {
if(aux->a[s[i] - 'a'] == NULL)
aux->a[s[i] - 'a'] = new trie();
if(i%2 == 0)
aux->can[s[i] - 'a'] = 1;
aux = aux->a[s[i] - 'a'];
aux->sz = i+1;
}
}
cin >> n;
while(n--) {
string s;
cin >> s;
trie *aux = x;
for(int i = 0; i < s.size(); i++) {
if(aux->a[s[i] - 'a'] == NULL)
aux->a[s[i] - 'a'] = new trie();
if(i & 1)
aux->can[s[i] - 'a'] = 1;
aux = aux->a[s[i] - 'a'];
aux->sz = i+1;
}
}
cout << (dfs(x) ? "Emilija" : "Nina") << endl;
}
컴파일 시 표준 에러 (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... |