# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
425228 | keta_tsimakuridze | Vlak (COCI20_vlak) | C++14 | 36 ms | 19224 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int aft[N][30],fix[N][2],cur,n,m;
vector<int>V[N];
string s;
void add(string s,int f){
int u = 0;
for(int i=0;i<s.size();i++){
if(!aft[u][s[i]-'0']) {
cur++;
aft[u][s[i]-'0'] = cur; V[u].push_back(aft[u][s[i]-'0']);
}
u = aft[u][s[i]-'0'];
fix[u][f] = 1;
}
}
bool dfs(int u,int f) {
int o = 0;
//cout<< f << " "<< u << endl;
if(!fix[u][f]) return 0;
if(!fix[u][1-f]) return 1;
for(int i=0;i<V[u].size();i++){
bool x = dfs(V[u][i],1^f);
o|=x;
// cout<<u<<" "<<f<<" "<<x<<endl;
}
return o^1;
}
int main(){
cin>>n;
for(int i=1;i<=n;i++){
cin>>s;
add(s,0);
} cout<<endl;
cin>>m;
for(int i=1;i<=m;i++){
cin>>s;
add(s,1);
}
int x = 0;
for(int i=0;i<V[0].size();i++) x|=dfs(V[0][i],0);
if(x) cout<<"Nina"; else cout<<"Emilija";
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |