#include <bits/stdc++.h>
using namespace std;
struct TrieNode {
TrieNode() {
canWin[0] = canWin[1] = -1;
memset(child, 0, sizeof child);
}
int canWin[2];
bool hasColor[2];
int child[26];
};
struct Trie {
Trie() {
fetchNode();
root = fetchNode();
}
void insertWord(const string& s, int color) {
int current = root;
for (int i = 0; i < (int)s.size(); ++i) {
int edge = s[i] - 'a';
if (nodes[current].child[edge] == 0) {
nodes[current].child[edge] = fetchNode();
}
current = nodes[current].child[edge];
nodes[current].hasColor[color] = true;
}
}
int canWin(int node, int turn) {
int& ret = nodes[node].canWin[turn];
if (ret != -1) {
return ret;
}
for (int edge = 0; edge < 26; ++edge) {
int child = nodes[node].child[edge];
if (child != 0 && nodes[child].hasColor[turn] == true && canWin(child, turn ^ 1) == false) {
return ret = 1;
}
}
return ret = 0;
}
int fetchNode() {
nodes.push_back(TrieNode());
return (int)nodes.size() - 1;
}
int root;
vector<TrieNode> nodes;
};
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
Trie trie;
int n;
cin >> n;
while (n--) {
string s;
cin >> s;
trie.insertWord(s, 0);
}
int m;
cin >> m;
while (m--) {
string s;
cin >> s;
trie.insertWord(s, 1);
}
cout << "WA";
//cout << (trie.canWin(1, 0) == 1 ? "Nina" : "Emilija");
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
876 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
868 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
872 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
872 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
868 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |