| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 688333 | danikoynov | Vlak (COCI20_vlak) | C++14 | 25 ms | 23208 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define endl "\n"
using namespace std;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
const int alphabet = 26;
const int maxn = 2e5 + 10;
struct trie
{
int nxt[alphabet], state[2];
bool leaf, is_word[2];
trie()
{
memset(nxt, -1, sizeof(nxt));
leaf = true;
is_word[0] = is_word[1] = false;
state[0] = state[1] = 0;
}
}tree[maxn];
int last_used;
void add(int root, string &word, int pos, int player)
{
if (pos == word.size())
{
tree[root].is_word[player] = 1;
return;
}
int &neib = tree[root].nxt[word[pos] - 'a'];
if (neib == -1)
neib = ++ last_used;
tree[root].leaf = false;
add(neib, word, pos + 1, player);
tree[root].is_word[0] |= tree[neib].is_word[0];
tree[root].is_word[1] |= tree[neib].is_word[1];
}
void dfs(int root)
{
if (tree[root].leaf)
{
tree[root].state[0] = tree[root].state[1] = 0;
return;
}
if (tree[root].is_word[0] == false)
{
///cout << "GOOD " << root << endl;
tree[root].state[0] = 0;
tree[root].state[1] = 1;
return;
}
if (tree[root].is_word[1] == false)
{
///cout << "BAD " << root << endl;
tree[root].state[0] = 1;
tree[root].state[1] = 0;
return;
}
int neib;
for (int i = 0; i < alphabet; i ++)
{
neib = tree[root].nxt[i];
if (neib == -1)
continue;
dfs(neib);
/**cout << root << " : " << neib << endl;
cout << tree[neib].is_word[1] << endl;
cout << tree[neib].state[0] << endl;*/
if (!tree[neib].state[0] && tree[neib].is_word[1])
tree[root].state[1] = true;
if (!tree[neib].state[1] && tree[neib].is_word[0])
tree[root].state[0] = true;
}
///cout << "back " << root << " " << tree[root].state[0] << " : " << tree[root].state[1] << endl;
}
int n, m;
void solve()
{
string word;
cin >> n;
for (int i = 1; i <= n; i ++)
{
cin >> word;
add(0, word, 0, 0);
}
cin >> m;
for (int i = 1; i <= m; i ++)
{
cin >> word;
add(0, word, 0, 1);
}
dfs(0);
if (tree[0].state[0])
cout << "Nina" << endl;
else
cout << "Emilija" << endl;
}
int main()
{
solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
