# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
692236 |
2023-02-01T08:38:18 Z |
tamthegod |
Vlak (COCI20_vlak) |
C++17 |
|
55 ms |
96472 KB |
// Make the best become better
// No room for laziness
#include<bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int maxN = 1e6 + 5;
const int mod = 1e9 + 7;
const ll oo = 1e18;
int n, m;
string s[maxN], t[maxN];
void ReadInput()
{
cin >> n;
for(int i=1; i<=n; i++)
cin >> s[i];
cin >> m;
for(int i=1; i<=m; i++)
cin >> t[i];
}
struct Trie
{
struct TNode
{
int id;
int type;
int child[30];
};
vector<TNode> tree;
void new_node()
{
TNode tmp;
tmp.id = tree.size();
tmp.type = 0;
for(int i=0; i<30; i++)
tmp.child[i] = -1;
tree.pb(tmp);
}
void add(string s, int type)
{
int id = 0;
for(char c : s)
{
int w = c - 'a';
if(tree[id].child[w] == -1)
{
new_node();
tree[id].child[w] = tree.size() - 1;
}
id = tree[id].child[w];
tree[id].type |= type;
}
tree[id].type = type;
}
bool get(int id, int turn)
{
if(!(turn & 1))
{
bool ok = false;
for(int w=0; w<27; w++)
{
if(tree[id].child[w] != -1 && tree[tree[id].child[w]].type >= 2)
{
ok |= get(tree[id].child[w], turn ^ 1);
}
}
if(id == 5)
{
// cout << ok;exit(0);
}
return ok;
}
else
{
bool ok = true;
for(int w=0; w<27; w++)
{
if(tree[id].child[w] != -1 && tree[tree[id].child[w]].type != 2)
{
ok &= get(tree[id].child[w], turn ^ 1);
}
}
if(id == 4)
{
//cout << ok;exit(0);
}
return ok;
}
}
};
void Solve()
{
Trie trie;
trie.new_node();
for(int i=1; i<=n; i++)
trie.add(s[i], 1);
for(int i=1; i<=m; i++)
trie.add(t[i], 2);
// cout << trie.tree[5].type;exit(0);
// cout << trie.tree[4].child[1];return;
// cout << trie.tree[4].type;return;
cout << (trie.get(0, 0) ? "Nina" : "Emilija");
}
int32_t main()
{
// freopen("CONC.inp", "r", stdin);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
ReadInput();
Solve();
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
63572 KB |
Output is correct |
2 |
Correct |
30 ms |
63584 KB |
Output is correct |
3 |
Incorrect |
29 ms |
63600 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
29 ms |
63540 KB |
Output is correct |
2 |
Correct |
30 ms |
63520 KB |
Output is correct |
3 |
Incorrect |
30 ms |
63544 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
63228 KB |
Output is correct |
2 |
Incorrect |
29 ms |
63588 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
33 ms |
63264 KB |
Output is correct |
2 |
Correct |
30 ms |
63528 KB |
Output is correct |
3 |
Correct |
30 ms |
63488 KB |
Output is correct |
4 |
Correct |
29 ms |
63332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
96212 KB |
Output is correct |
2 |
Incorrect |
55 ms |
96472 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
55 ms |
96164 KB |
Output is correct |
2 |
Incorrect |
54 ms |
96308 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
53 ms |
96180 KB |
Output is correct |
2 |
Incorrect |
54 ms |
96408 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |