# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1015908 |
2024-07-07T04:29:10 Z |
vjudge1 |
Vlak (COCI20_vlak) |
C++17 |
|
14 ms |
15680 KB |
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,popcnt,lzcnt")
#define _GLIBCXX_FILESYSTEM
#include<bits/stdc++.h>
using namespace std;
#define ll long long
struct Trie{
struct node{
int nxt[26];
node(){
memset(nxt,-1,sizeof(nxt));
}
};
vector<node> trie;
Trie(){
trie.emplace_back();
}
void insert(string &s){
int cur = 0;
for(int i = 0; i < s.size(); i++){
if(trie[cur].nxt[s[i]-'a'] == -1){
trie[cur].nxt[s[i]-'a'] = trie.size();
trie.push_back(node());
}
cur = trie[cur].nxt[s[i]-'a'];
}
}
};
Trie nina,emil;
int dfs(int i,int j,int cur){
for(int k = 0; k < 26; k++){
if(cur){
if(emil.trie[j].nxt[k] != -1 and nina.trie[i].nxt[k] == -1) return 1;
}
else{
if(nina.trie[i].nxt[k] != -1 and emil.trie[j].nxt[k] == -1) return 1;
}
}
vector<bool> mex(27,0);
for(int k = 0; k < 26; k++){
if(emil.trie[j].nxt[k] != -1 and nina.trie[i].nxt[k] != -1){
int now = dfs(nina.trie[i].nxt[k],emil.trie[j].nxt[k],cur^1);
if(now < 27) mex[now] = 1;
}
}
for(int k = 0; k < 27; k++){
if(!mex[k]) return k;
}
}
void solve() {
int n;
cin >> n;
for(int i = 0; i < n; i++){
string s;
cin >> s;
nina.insert(s);
}
int m;
cin >> m;
for(int i = 0; i < m; i++){
string s;
cin >> s;
emil.insert(s);
}
if(dfs(0,0,0)) cout << "Nina\n";
else cout << "Emilija\n";
return;
}
int32_t main() {
ios_base::sync_with_stdio(false);cin.tie(NULL);
int tc = 1;
// cin >> tc;
for(int kase = 1; kase <= tc; kase++) {
//cout << "Case " << kase << ": ";
solve();
}
return 0;
}
Compilation message
Main.cpp: In member function 'void Trie::insert(std::string&)':
Main.cpp:22:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | for(int i = 0; i < s.size(); i++){
| ~~^~~~~~~~~~
Main.cpp: In function 'int dfs(int, int, int)':
Main.cpp:42:26: warning: control reaches end of non-void function [-Wreturn-type]
42 | vector<bool> mex(27,0);
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
1 ms |
600 KB |
Output is correct |
3 |
Correct |
0 ms |
456 KB |
Output is correct |
4 |
Correct |
1 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
604 KB |
Output is correct |
2 |
Correct |
1 ms |
604 KB |
Output is correct |
3 |
Correct |
0 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Correct |
0 ms |
604 KB |
Output is correct |
3 |
Correct |
1 ms |
604 KB |
Output is correct |
4 |
Correct |
0 ms |
604 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
11 ms |
15304 KB |
Output is correct |
2 |
Correct |
11 ms |
15096 KB |
Output is correct |
3 |
Correct |
14 ms |
14796 KB |
Output is correct |
4 |
Correct |
11 ms |
15308 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
15304 KB |
Output is correct |
2 |
Correct |
10 ms |
15680 KB |
Output is correct |
3 |
Correct |
11 ms |
15308 KB |
Output is correct |
4 |
Correct |
10 ms |
15304 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
15300 KB |
Output is correct |
2 |
Correct |
13 ms |
15048 KB |
Output is correct |
3 |
Correct |
11 ms |
15048 KB |
Output is correct |
4 |
Correct |
11 ms |
15556 KB |
Output is correct |