# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
156273 | 2019-10-04T17:21:49 Z | mdn2002 | Cezar (COCI16_cezar) | C++14 | 30 ms | 23928 KB |
#include<bits/stdc++.h> using namespace std; long long mod=1e9+7; vector<string>v,an; vector<int>gr[1000004]; vector<char>ans; int n,d[1005],vis[1030],tt=1; int dt[1030]; void dfs(int x) { dt[x-1]=tt++; vis[x]=1; for(int i=0; i<gr[x].size(); i++) { int u=gr[x][i]; if(vis[u]==1) { cout<<"NE"; exit(0); } else if(vis[u]==0)dfs(u); } vis[x]=2; } int main() { cin>>n; for(int i=0; i<n; i++) { string s; cin>>s; v.push_back(s); } for(int i=0; i<n; i++) { cin>>d[i]; an.push_back(v[d[i]-1]); } for(int i=0; i<n-1; i++) { int x=0; while(an[i][x]==an[i+1][x]) { x++; if(x>=an[i].size()||x>=an[i+1].size()) { if(an[i].size()>an[i+1].size()) { cout<<"NE"; return 0; } break; } } if(x<an[i].size()&&x<an[i+1].size())gr[(an[i][x]-'a')+1].push_back((an[i+1][x]-'a')+1); } for(int i=0; i<n-1; i++) { int x=0; while(an[i][x]==an[i+1][x]) { x++; } if(x-1!=min(an[i].size(),an[i+1].size())) { dfs(an[0][x]-'a'+1); break; } if(i==n-2) { cout<<"NE"; return 0; } } cout<<"DA"<<endl; for(int i=0; i<26; i++) { if(dt[i]!=0)ans.push_back('a'+(dt[i]-1)); else { ans.push_back('a'+(tt-1)); tt++; } } for(int i=0; i<26; i++) { cout<<ans[i]; } } /* 2 abc ab 1 2 */
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 23928 KB | Output is correct |
2 | Correct | 23 ms | 23800 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 23800 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 23800 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 23848 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 30 ms | 23928 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 23776 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 23800 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 23 ms | 23800 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 23800 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 24 ms | 23772 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |