Submission #373261

#TimeUsernameProblemLanguageResultExecution timeMemory
373261sam571128Vlak (COCI20_vlak)C++14
70 / 70
30 ms20972 KiB
#include <bits/stdc++.h> #define int long long #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); using namespace std; const int N = 2e5+5; int tr[N][26], win[N], p[N][2], cnt = 0; void insert(string &s, int player){ int now = 0; for(auto c : s){ p[now][player] = 1; if(!tr[now][c-'a']) now = tr[now][c-'a'] = ++cnt; else now = tr[now][c-'a']; } p[now][player] = 1; } void dfs(int now, int turn = 1){ bool has = 0, ok = 0; for(int i = 0;i < 26;i++){ if(!tr[now][i]) continue; dfs(tr[now][i],turn^1); ok = 1; if(win[tr[now][i]]) has = 1; } if(!ok){ if(p[now][turn]) win[now] = 1; }else if(!has) win[now] = 1; } signed main(){ fastio int n; cin >> n; for(int i = 0;i < n;i++){ string s; cin >> s; insert(s,0); } int m; cin >> m; for(int i = 0;i < m;i++){ string s; cin >> s; insert(s,1); } dfs(0); bool ww = 0; for(int i = 0;i < 26;i++){ if(tr[0][i]){ ww |= win[tr[0][i]]; } } cout << (ww ? "Nina" : "Emilija") << "\n"; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...