Submission #880740

#TimeUsernameProblemLanguageResultExecution timeMemory
880740Ahmed_SolymanVlak (COCI20_vlak)C++14
70 / 70
21 ms22620 KiB
#include <bits/stdc++.h> #include <ext/rope> using namespace std; using namespace __gnu_cxx; #pragma GCC optimize("-Ofast") #pragma GCC optimize("-O1") //-------------------------------------------------------------// typedef long long ll; typedef unsigned long long ull; #define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); #define PI acos(-1) #define lb lower_bound #define ub upper_bound #define endl '\n' #define all(v) v.begin(),v.end() #define allr(v) v.rbegin(),v.rend() #define sum_to(n) (n*(n+1))/2 #define pb push_back #define pf push_front #define fil(arr,x) memset(arr,x,sizeof(arr)) const ll mod=1e9+7; int dx[8]={0,1,0,-1,1,1,-1,-1}; int dy[8]={1,0,-1,0,1,-1,-1,1}; //-------------------------------------------------------------// ll lcm(ll a,ll b) { return (max(a,b)/__gcd(a,b))*min(a,b); } void person_bool(bool x) { cout<<(x?"YES":"NO")<<endl; } int cnt=0; struct node{ node *a[26]; int stop[3],id; }; node *New(){ node *ret=new node; for(int i=0;i<26;i++){ ret->a[i]=NULL; } ret->id=cnt++; ret->stop[1]=ret->stop[2]=0; return ret; } void insert(node *root,string s,int typ){ node *temp=root; for(int i=0;i<(int)s.size();i++){ if(temp->a[s[i]-'a']==NULL){ temp->a[s[i]-'a']=New(); } temp=temp->a[s[i]-'a']; } temp->stop[typ]=1; } void build(node *node){ for(int i=0;i<26;i++){ if(node->a[i]==NULL){ continue; } build(node->a[i]); for(int j=1;j<=2;j++){ node->stop[j] |= node->a[i]->stop[j]; } } } int dp[200005]; int solve(node *node,int i){ int &ret=dp[node->id]; if(~ret)return ret; if(i%2==0){ ret=0; for(int j=0;j<26;j++){ if(node->a[j]==NULL){ continue; } if(node->a[j]->stop[1]){ ret|=solve(node->a[j],i+1); } } return ret; } else{ ret=0; for(int j=0;j<26;j++){ if(node->a[j]==NULL){ continue; } if(node->a[j]->stop[2]){ ret|=!solve(node->a[j],i+1); } } ret ^= 1; return ret; } } int main() { //freopen("input.in","r",stdin); // freopen("output.out","w",stdout); fast node *root=New(); int n,m; cin>>n; for(int i=0;i<n;i++){ string s;cin>>s; insert(root,s,1); } cin>>m; for(int i=0;i<m;i++){ string s;cin>>s; insert(root,s,2); } build(root); fil(dp,-1); cout<<(solve(root,0)?"Nina":"Emilija")<<endl; 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...