Submission #798954

# Submission time Handle Problem Language Result Execution time Memory
798954 2023-07-31T08:01:11 Z yeediot Vlak (COCI20_vlak) C++14
0 / 70
16 ms 20348 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(char now,int turn,int v1,int v2){
    //cout<<v1<<' '<<v2<<'\n';
    bool ok=1;
    if(now!=' '){
        if(turn==0){
            if(trie[turn][v1][now-'a']){
                v1=trie[turn][v1][now-'a'];
            }
            else{
                return 1-turn;
            }
        }
        else{
            if(trie[turn][v2][now-'a']){
                v2=trie[turn][v2][now-'a'];
            }
            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(('a'+i),1-turn,trie[turn][v1][i],v2)==0){
                    ok=0;
                }
            }
        }
        else{
            if(trie[turn][v2][i]){
                //cout<<(char)(i+'a');
                if(calc(('a'+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(' ',0,0,0)==0?"Nina":"Emilija")<<'\n';
}

# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 580 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Incorrect 1 ms 596 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 448 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Incorrect 1 ms 468 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 468 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 468 KB Output is correct
4 Incorrect 1 ms 588 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 20340 KB Output is correct
2 Incorrect 16 ms 19172 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 20348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 15 ms 19480 KB Output isn't correct
2 Halted 0 ms 0 KB -