# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
798982 |
2023-07-31T08:21:56 Z |
yeediot |
Vlak (COCI20_vlak) |
C++14 |
|
20 ms |
20992 KB |
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pb push_back
#define sz(x) (int)(x.size())
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define vi vector<int>
#define vp vector<pii>
#define vvi vector<vi>
const int mxn=2e5+5;
int trie[2][mxn][26];
int nxt=1;
vector<string>s,ss;
int n,m;
void add(string s,int type){
int i=0,v=0;
while(i<sz(s)){
//cout<<v<<' ';
if(trie[type][v][s[i]-'a']){
v=trie[type][v][s[i++]-'a'];
}
else{
v=trie[type][v][s[i++]-'a']=nxt++;
}
}//cout<<v<<'\n';
}
bool calc(int now,int turn,int v1,int v2){
for(int i=0;i<26;i++){
int a=trie[0][v1][i];
int b=trie[1][v2][i];
if(turn==0){
if(a and !b)return 0;
if(a and b and !calc(i,1,a,b))return 0;
}
else{
if(!a and b)return 1;
if(a and b and calc(i,0,a,b))return 1;
}
}
return 1-turn;
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);cout.tie(0);
cin>>n;
for(int i=0;i<n;i++){
string temp;
cin>>temp;
add(temp,0);
}
cin>>m;
nxt=1;
for(int i=0;i<m;i++){
string temp;
cin>>temp;
add(temp,1);
}
cout<<(calc(0,0,0,0)==0?"Nina":"Emilija")<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
584 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
584 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
0 ms |
596 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
19424 KB |
Output is correct |
2 |
Correct |
14 ms |
18312 KB |
Output is correct |
3 |
Correct |
14 ms |
17496 KB |
Output is correct |
4 |
Correct |
14 ms |
19160 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
14 ms |
19796 KB |
Output is correct |
2 |
Correct |
14 ms |
20992 KB |
Output is correct |
3 |
Correct |
16 ms |
19268 KB |
Output is correct |
4 |
Correct |
13 ms |
19520 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
13 ms |
18772 KB |
Output is correct |
2 |
Correct |
18 ms |
18456 KB |
Output is correct |
3 |
Correct |
15 ms |
18980 KB |
Output is correct |
4 |
Correct |
20 ms |
20196 KB |
Output is correct |