# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
415961 |
2021-06-01T18:31:09 Z |
fvogel499 |
Vlak (COCI20_vlak) |
C++14 |
|
1000 ms |
27520 KB |
/*
File created on 06/01/2021 at 20:08:52.
Link to problem: https://oj.uz/problem/view/COCI20_vlak
Description: create a trie and run a DP win/lose
Time complexity: O()
Space complexity: O()
Status: DEV
Copyright: Ⓒ 2021 Francois Vogel
*/
#include <iostream>
#include <cmath>
#include <vector>
#include <bitset>
#include <queue>
#include <cstring>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
using namespace std;
#define pb push_back
#define ins insert
#define cls clear
#define ll long long
const int siz = 2e5;
struct Node {
Node(char lt) {
t = lt;
for (int i = 0; i < 26; i++) c[i] = nullptr;
}
void add(string& s, int player) {
if (!s.empty()) {
int i = s[s.size()-1]-'a';
if (c[i] == nullptr) c[i] = new Node(s[s.size()-1]);
p[player].pb(c[i]);
s.pop_back();
c[i]->add(s, player);
}
}
char t;
Node* c [26];
vector<Node*> p [2];
};
// true if player wins if his turn is on node i, false otherwise
bool recDP(Node* i, int player) {
for (Node* j : i->p[player]) {
if (!recDP(j, (player == 0 ? 1 : 0))) {
return true;
}
}
return false;
}
signed main() {
cin.tie(0);
// ios_base::sync_with_stdio(0);
Node* root = new Node('$');
int aS;
cin >> aS;
for (int i = 0; i < aS; i++) {
string lS;
cin >> lS;
reverse(lS.begin(), lS.end());
root->add(lS, 0);
}
int bS;
cin >> bS;
for (int i = 0; i < bS; i++) {
string lS;
cin >> lS;
reverse(lS.begin(), lS.end());
root->add(lS, 1);
}
bool res = recDP(root, 0);
if (res) cout << "Nina";
else cout << "Emilija";
int d = 0;
d++;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1082 ms |
588 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
676 KB |
Output is correct |
2 |
Correct |
2 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
2 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
544 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
15 ms |
588 KB |
Output is correct |
4 |
Correct |
1 ms |
588 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
552 KB |
Output is correct |
2 |
Correct |
2 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
588 KB |
Output is correct |
4 |
Correct |
2 ms |
708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1077 ms |
26856 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1067 ms |
27520 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1085 ms |
25956 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |