# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1087775 | shidou26 | Vlak (COCI20_vlak) | C++14 | 46 ms | 83216 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
const int N = 1e6 + 3;
struct node {
int state;
node *children[26];
node () {
state = 0;
for(int i = 0; i < 26; i++) {
children[i] = nullptr;
}
}
};
int n, m;
string a[N], b[N];
node *root = new node();
void prepare() {
}
void input() {
cin >> n;
for(int i = 1; i <= n; i++) {
cin >> a[i];
}
cin >> m;
for(int i = 1; i <= n; i++) {
cin >> b[i];
}
}
void insert(string s, int type) {
node *current = root;
for(int i = 0; i < (int)s.size(); i++) {
int ch = s[i] - 'a';
if(current -> children[ch] == nullptr)
current -> children[ch] = new node();
current = current -> children[ch];
current -> state |= type;
}
}
bool dfs(node *current, int turn) {
if(!(current->state & turn)) return false;
for(int i = 0; i < 26; i++) {
if(current -> children[i] != nullptr && !dfs(current -> children[i], 3 - turn)) {
return true;
}
}
return false;
}
void process() {
root -> state = 3;
for(int i = 1; i <= n; i++) insert(a[i], 1);
for(int i = 1; i <= m; i++) insert(b[i], 2);
cout << (dfs(root, 1) ? "Nina" : "Emilija") << endl;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
#define task "kurumi"
if(fopen(task".INP", "r")) {
freopen(task".INP", "r", stdin);
freopen(task".OUT", "w", stdout);
}
prepare();
int testcase = 1; // cin >> testcase;
for(int i = 1; i <= testcase; i++) {
input();
process();
}
return 0;
}
컴파일 시 표준 에러 (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... |