# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133383 | 2019-07-20T13:18:56 Z | forelax | Cezar (COCI16_cezar) | C++14 | 3 ms | 376 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 252 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 256 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |