# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
798957 |
2023-07-31T08:04:15 Z |
yeediot |
Vlak (COCI20_vlak) |
C++14 |
|
0 ms |
0 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){
//cout<<v1<<' '<<v2<<'\n';
bool ok=1;
if(now!=-1){
if(turn==0){
if(trie[turn][v1][i]){
v1=trie[turn][v1][i];
}
else{
return 1-turn;
}
}
else{
if(trie[turn][v2][i]){
v2=trie[turn][v2][i];
}
else{
return 1-turn;
}
}
}
for(int i=0;i<26;i++){
if(turn==0){
if(trie[turn][v1][i]){
//cout<<(char)(i+'a');
if(calc(i,1-turn,trie[turn][v1][i],v2)==0){
ok=0;
}
}
}
else{
if(trie[turn][v2][i]){
//cout<<(char)(i+'a');
if(calc(i,1-turn,v1,trie[turn][v2][i])==0){
ok=0;
}
}
}
}
//cout<<'\n';
return ok;
}
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;
s.pb(temp);
add(temp,0);
}
cin>>m;
nxt=1;
for(int i=0;i<m;i++){
string temp;
cin>>temp;
ss.pb(temp);
add(temp,1);
}
cout<<(calc(-1,0,0,0)==0?"Nina":"Emilija")<<'\n';
}
Compilation message
Main.cpp: In function 'bool calc(long long int, long long int, long long int, long long int)':
Main.cpp:37:31: error: 'i' was not declared in this scope
37 | if(trie[turn][v1][i]){
| ^
Main.cpp:45:31: error: 'i' was not declared in this scope
45 | if(trie[turn][v2][i]){
| ^