# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1021658 | TrendBattles | Vlak (COCI20_vlak) | C++14 | 17 ms | 14684 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
using lli = int64_t;
#define INFILE "vlak.inp"
#define OUTFILE "vlak.out"
const int MAX_AL = 26;
struct Node {
int available = 0;
int child[MAX_AL];
Node() {
memset(child, -1, sizeof child);
}
};
vector <Node> trie(1);
void add(const string& s, int who) {
int now = 0;
for (char x : s) {
int nxt = trie[now].child[x - 'a'];
if (nxt == -1) {
nxt = trie.size();
trie[now].child[x - 'a'] = nxt;
trie.emplace_back();
}
now = nxt;
trie[now].available |= 1 << who;
}
}
int main() {
ios::sync_with_stdio(0); cin.tie(0);
if (fopen(INFILE, "r")) {
freopen(INFILE, "r", stdin);
freopen(OUTFILE, "w", stdout);
}
for (int i : {0, 1}) {
int N; cin >> N;
for (int t = 1; t <= N; ++t) {
string S; cin >> S;
add(S, i);
}
}
vector <int> dp((int) trie.size() + 100, -1);
auto DP = [&] (auto self, int u, int turn) -> int {
int& now = dp[u];
if (now != -1) return now;
now = 0;
for (int i = 0; i < 26; ++i) {
if (trie[u].child[i] == -1) continue;
int v = trie[u].child[i];
if ((trie[v].available >> turn & 1) == 0) continue;
now |= not self(self, v, turn ^ 1);
}
return now;
};
cout << (DP(DP, 0, 0) ? "Nina" : "Emilija");
return 0;
}
Compilation message (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... |