Submission #692145

# Submission time Handle Problem Language Result Execution time Memory
692145 2023-02-01T07:35:53 Z vjudge1 Vlak (COCI20_vlak) C++17
70 / 70
19 ms 14824 KB
#define taskname "CONC"
#include <bits/stdc++.h>
using namespace std;
using ld = long double;
using ll = long long;
struct node{
int nxt[26];
int vis[2];
node(){
vis[0]=vis[1]=0;
memset(nxt,-1,sizeof(nxt));
}
};
vector<node>trie;
void add(string s,bool t){
int n=0;
for (auto v:s){
    int num=v-'a';
    if (trie[n].nxt[num]==-1){
        trie[n].nxt[num]=trie.size();
        node temp;
        trie.push_back(temp);
    }
    n=trie[n].nxt[num];
    trie[n].vis[t]=1;
}
}
int dfs(int u,bool t){
if (trie[u].vis[t]==0)return 0;
int dm=0;
for (int j=0;j<26;j++){
    if (trie[u].nxt[j]==-1)continue;
    int nw=trie[u].nxt[j];
    if (trie[nw].vis[t]){
        dm=max(dm,1-dfs(nw,1-t));
    }
}
return dm;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
//    freopen(taskname".INP","r",stdin);
//    freopen(taskname".OUT","w",stdout);
    node temp;
    temp.vis[0]=temp.vis[1]=1;
    trie.push_back(temp);
    int n;
    cin>>n;
    for (int i=1;i<=n;i++){
        string s;
        cin>>s;
        add(s,0);
    }
    int m;
    cin>>m;
    for (int i=1;i<=m;i++){
        string s;
        cin>>s;
        add(s,1);
    }
    if (dfs(0,0))cout<<"Nina";
    else cout<<"Emilija";
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 660 KB Output is correct
2 Correct 0 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 0 ms 596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 596 KB Output is correct
2 Correct 1 ms 596 KB Output is correct
3 Correct 1 ms 596 KB Output is correct
4 Correct 1 ms 596 KB Output is correct
# 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 Correct 1 ms 596 KB Output is correct
# 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 596 KB Output is correct
4 Correct 1 ms 468 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 19 ms 14788 KB Output is correct
2 Correct 17 ms 14748 KB Output is correct
3 Correct 15 ms 14824 KB Output is correct
4 Correct 19 ms 14812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 14764 KB Output is correct
2 Correct 16 ms 14792 KB Output is correct
3 Correct 14 ms 14776 KB Output is correct
4 Correct 16 ms 14824 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 14788 KB Output is correct
2 Correct 14 ms 14788 KB Output is correct
3 Correct 15 ms 14788 KB Output is correct
4 Correct 15 ms 14788 KB Output is correct