# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
446566 | Arinoor | Vlak (COCI20_vlak) | C++17 | 22 ms | 20428 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pai
typedef long long ll;
const int maxn = 2e5 + 10;
const int maxalpha = 26;
const int inf = 1e9 + 10;
const int mod = 1e9 + 7;
struct Trie{
struct node{
node * child[maxalpha];
bool N, E;
int h;
node(){
for(int i = 0; i < maxalpha; i ++)
child[i] = nullptr;
N = E = false;
h = 0;
}
node *getChild(int c){
if(child[c] == nullptr){
child[c] = new node();
child[c]->h = h + 1;
}
return child[c];
}
};
node * root;
Trie(){
root = new node();
}
void add(const string *s, char player){
node *cur = root;
for(char c : *s){
cur = cur->getChild(c - 'a');
if(player == 'N')
cur->N = true;
else
cur->E = true;
}
}
bool dfs(node *v){
bool fg = false;
for(int i = 0; i < maxalpha; i ++){
if(v->child[i] != nullptr){
node *u = v->child[i];
if(v->h % 2 == 0 and u->N or v->h % 2 == 1 and u->E){
if(!dfs(u))
fg = true;
}
}
}
return fg;
}
} T;
int main(){
ios;
int n;
cin >> n;
for(int i = 0; i < n; i ++){
string s;
cin >> s;
T.add(&s, 'N');
}
int m;
cin >> m;
for(int i = 0; i < m; i ++){
string s;
cin >> s;
T.add(&s, 'E');
}
if(T.dfs(T.root))
cout << "Nina\n";
else
cout << "Emilija\n";
}
컴파일 시 표준 에러 (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... |