# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133343 | 2019-07-20T12:22:24 Z | forelax | Cezar (COCI16_cezar) | C++14 | 3 ms | 404 KB |
#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); if(!good)return; } } 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
# | 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 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 380 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 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 | Correct | 2 ms | 380 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 404 KB | Output is correct |
# | 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 | Incorrect | 2 ms | 372 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |