# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
415976 |
2021-06-01T18:45:40 Z |
fvogel499 |
Vlak (COCI20_vlak) |
C++14 |
|
48 ms |
28620 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
struct Node {
Node() {
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();
p[player].pb(c[i]);
s.pop_back();
c[i]->add(s, player);
}
}
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;
string lS;
for (int i = 0; i < aS; i++) {
cin >> lS;
reverse(lS.begin(), lS.end());
root->add(lS, 0);
}
int bS;
cin >> bS;
for (int i = 0; i < bS; i++) {
cin >> lS;
reverse(lS.begin(), lS.end());
root->add(lS, 1);
}
bool res = false;//recDP(root, 0);
if (res) cout << "Nina";
else cout << "Emilija";
int d = 0;
d++;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
588 KB |
Output is correct |
2 |
Incorrect |
2 ms |
588 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
48 ms |
26816 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
40 ms |
27560 KB |
Output is correct |
2 |
Correct |
38 ms |
28620 KB |
Output is correct |
3 |
Correct |
36 ms |
26528 KB |
Output is correct |
4 |
Incorrect |
34 ms |
27004 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
38 ms |
25992 KB |
Output is correct |
2 |
Correct |
41 ms |
25448 KB |
Output is correct |
3 |
Incorrect |
36 ms |
26008 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |