Submission #133383

#TimeUsernameProblemLanguageResultExecution timeMemory
133383forelaxCezar (COCI16_cezar)C++14
10 / 100
3 ms376 KiB
#include<bits/stdc++.h> using namespace std; vector<int> visited(26),visiting(26),order; vector<vector<int> > dir(26,vector<int> (26)); bool good=true; void dfs(int ind){ for(int i = 0 ; i < 26 ; i ++){ if(visited[i]||!dir[ind][i])continue; if(visiting[i]){ good=false; return; } visiting[i]=true; dfs(i); if(!good)return; } order.push_back(ind); visited[ind]=true; } int main(){ int n; cin>>n; vector<string> a(n),b(n); for(int i = 0 ; i < n ; i ++){ cin>>a[i]; } for(int i = 0,t ; i < n ; i ++){ cin>>t;t--; b[i]=a[t]; } for(int i = 0,k ; i < n ; i ++){ for(int j = i+1 ; j < n ; j ++){ int l=min(b[i].length(),b[j].length()); for( k=0 ; k<l ; k ++) if(b[i][k]!=b[j][k])break; if(k==b[j].length()){ cout<<"NE"; return 0; } if(k==b[i].length()){ continue; } dir[b[i][k]-'a'][b[j][k]-'a']=true; } } for(int i = 0 ; i < 26 ; i ++){ if(visited[i])continue; visiting[i]=true; dfs(i); if(!good){ cout<<"NE"; return 0; } } vector<char> rez(26); for(int i = 0 ; i < order.size() ; i ++) rez[order[i]]=char('z'-i); cout<<"DA"<<endl; for(int i = 0 ; i < 26 ; i ++) cout<<rez[i]; }

Compilation message (stderr)

cezar.cpp: In function 'int main()':
cezar.cpp:36:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(k==b[j].length()){
                ~^~~~~~~~~~~~~~~
cezar.cpp:40:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             if(k==b[i].length()){
                ~^~~~~~~~~~~~~~~
cezar.cpp:56:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0 ; i < order.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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...