# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170475 | 2019-12-25T11:41:30 Z | mdn2002 | Cezar (COCI16_cezar) | C++14 | 1000 ms | 504 KB |
#include<bits/stdc++.h> using namespace std; const long long mod=998244353; int n,vis[39]; vector<int>gr[40]; vector<string>v,a; string s; void ckl(int x) { 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)ckl(u); } vis[x]=2; } void dfs(int x) { vis[x-1]=1; s.push_back((x+'a')-1); for(int i=0;i<gr[x].size();i++) { int u=gr[x][i]; if(vis[u-1])continue; dfs(u); } } int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); //freopen("lemonade.in","r",stdin); //freopen("lemonade.out","w",stdout); cin>>n; for(int i=0;i<n;i++) { string s; cin>>s; v.push_back(s); } for(int i=0;i<n;i++) { int x; cin>>x; a.push_back(v[x-1]); } for(int i=0;i<n;i++) { for(int j=i+1;j<n;j++) { if(a[i].size()!=a[j].size()) { int x=0; while(true)x++; } for(int z=0;z<a[i].size();z++) { if(a[i][z]!=a[j][z]) { gr[(a[i][z]-'a')+1].push_back((a[j][z]-'a')+1); break; } } } } for(int i=1;i<=30;i++) { if(vis[i]==0)ckl(i); } memset(vis,0,sizeof vis); for(int i=0;i<n;i++) { for(int j=0;j<a[i].size();j++) { if(vis[(a[i][j]-'a')]==0)dfs((a[i][j]-'a')+1); } } for(int i=0;i<='z'-'a';i++) { if(vis[i]==0)s.push_back(i+'a'); } cout<<"DA"<<endl<<s; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1080 ms | 504 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1084 ms | 504 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1075 ms | 376 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1073 ms | 504 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1074 ms | 376 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1086 ms | 252 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1084 ms | 376 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1050 ms | 376 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1073 ms | 504 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1054 ms | 504 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |