Submission #377831

#TimeUsernameProblemLanguageResultExecution timeMemory
377831kshitij_sodaniVlak (COCI20_vlak)C++14
70 / 70
20 ms10860 KiB
//#pragma GCC optimize("Ofast,unroll-loops") #include <bits/stdc++.h> using namespace std; typedef long long llo; #define mp make_pair #define pb push_back #define a first #define b second #define endl '\n' int n,m; int pre[200001][26]; int val[200001][2]; int dp[200001]; int co=0; void insert(string s,int ii){ int cur=0; for(int i=0;i<s.size();i++){ if(pre[cur][s[i]-'a']==0){ co++; pre[cur][s[i]-'a']=co; } cur=pre[cur][s[i]-'a']; val[cur][ii]++; } } void dfs(int no,int lev=0){ if(lev%2==0){ dp[no]=0; for(int j=0;j<26;j++){ if(pre[no][j]>0){ //cout<<no<<":"<<pre[no][j]<<":"<<j<<endl; dfs(pre[no][j],lev+1); if(val[pre[no][j]][0]>0){ dp[no]|=(1-dp[pre[no][j]]); } } } } else{ dp[no]=0; for(int j=0;j<26;j++){ if(pre[no][j]>0){ //cout<<no<<":"<<pre[no][j]<<":"<<j<<endl; dfs(pre[no][j],lev+1); if(val[pre[no][j]][1]>0){ dp[no]|=(1-dp[pre[no][j]]); } } } } // cout<<no<<",,"<<dp[no]<<endl; } int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n; for(int i=0;i<n;i++){ string s; cin>>s; insert(s,0); } cin>>m; for(int i=0;i<m;i++){ string s; cin>>s; insert(s,1); } dfs(0); if(dp[0]){ cout<<"Nina"<<endl; } else{ cout<<"Emilija"<<endl; } return 0; }

Compilation message (stderr)

Main.cpp: In function 'void insert(std::string, int)':
Main.cpp:18:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |  for(int i=0;i<s.size();i++){
      |              ~^~~~~~~~~
#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...