Submission #133320

#TimeUsernameProblemLanguageResultExecution timeMemory
133320forelaxCezar (COCI16_cezar)C++14
0 / 100
3 ms504 KiB
#include<bits/stdc++.h> using namespace std; bool good=true; vector<vector<bool> > dir(26,vector<bool> (26)); vector<bool> visited(26); vector<bool> visiting(26); vector<int> ord; void dfs(int i){ if(visiting[i]){ good=false; return; } visiting[i]=true; for(int j = 0 ; j < 26 ; j ++){ if(dir[i][j]&&!visited[j]){ dfs(j); } } ord.push_back(i); visited[i]=true; } int main(){ int n; cin>>n; vector<string> g(n),s(n); for(int i = 0 ; i < n ; i ++)cin>>g[i]; for(int i = 0,j ; i < n ; i ++){ cin>>j; s[i]=g[j-1]; } for(int i = 0 ; i < n ; i ++){ for(int j = i+1 ; j < n ; j ++){ for(int k = 0 ; true ; k ++){ if(k>s[i].length())break; if(k>s[j].length()){ cout<<"NE"; return 0; } if(s[i][k]==s[j][k])continue; dir[s[i][k]-'a'][s[j][k]-'a']=true; break; } } } for(int i = 25 ; i >= 0 ; i --){ if(!visited[i]){ dfs(i); if(!good){ cout<<"NE"; return 0; } } } cout<<"DA"<<endl; vector<char> rez(26); reverse(ord.begin(),ord.end()); for(int i = 0 ; i < 26 ; i ++){ rez[ord[i]]=char('a'+i); } for(int i = 0 ; i < rez.size() ; i ++)cout<<rez[i]; }

Compilation message (stderr)

cezar.cpp: In function 'int main()':
cezar.cpp:34:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(k>s[i].length())break;
                    ~^~~~~~~~~~~~~~
cezar.cpp:35:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(k>s[j].length()){
                    ~^~~~~~~~~~~~~~
cezar.cpp:60:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0 ; i < rez.size() ; i ++)cout<<rez[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...