Submission #467728

#TimeUsernameProblemLanguageResultExecution timeMemory
467728MohamedFaresNebiliVlak (COCI20_vlak)C++14
70 / 70
18 ms20428 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using db = double; using ii = pair<int, int>; using pl = pair<ll, ll>; using vi = vector<int>; using vl = vector<ll>; using vii = vector<ii>; using vpl = vector<pl>; #define mp make_pair #define pb push_back #define pp pop_back #define ff first #define ss second #define lb lower_bound #define ub upper_bound #define all(x) (x).begin() , (x).end() const int MOD = 1000*1000*1000+7; const long double EPS = 0.000000001; const long long INF = 1e18; struct node{ bool a=false, b=false; node* children[26]; node() { for(int l=0;l<26;l++) children[l]=nullptr; } }; node* root; void add(string s, bool t) { node* next=root; for(auto u:s) { int i=u-'a'; if(next->children[i]==nullptr) next->children[i]=new node(); if(t) { (next->children[i])->a=true; } else { (next->children[i])->b=true; } next=(next->children[i]); } if(t) { (next->a)=true; } else { (next->b)=true; } } bool solve(bool f, node* r) { bool player=f; node* next=r; for(int l=0;l<26;l++) { if((next->children[l])==nullptr) continue; if(player) { if((next->children[l])->a&&(next->children[l])->b==false) return player; else if(solve(!f, next->children[l])==player) return player; } else { if((next->children[l])->b&&(next->children[l])->a==false) return player; else if(solve(!f, next->children[l])==player) return player; } } return !player; } int32_t main() { ios::sync_with_stdio(0); cin.tie(0);cout.tie(0); /// freopen("closing.in", "r", stdin); /// freopen("closing.out", "w", stdout); int n; cin>>n; root=new node(); for(int l=0;l<n;l++) { string s; cin>>s; add(s, 1); } int m; cin>>m; for(int l=0;l<m;l++) { string s; cin>>s; add(s, 0); } cout<<(solve(1, root)==0?"Emilija":"Nina"); return 0; }
#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...