# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
81491 |
2018-10-25T03:38:20 Z |
ngot23 |
Cezar (COCI16_cezar) |
C++11 |
|
3 ms |
1592 KB |
#include<bits/stdc++.h>
#define rep(i, a, b) for(int i=(a) ; i<=(b) ; ++i)
#define Task ""
using namespace std;
const int N=30;
vector <int > g[N];
string s1[N], s2[N];
int n, visit[N], in[N], cur, c[N];
bool DFS(int u) {
visit[u]=1;
for(int v:g[u]) {
if(visit[v]==0) {
bool fl=DFS(v);
if(!fl) return false;
}
else if(visit[v]==1) return false;
}
visit[u]=2;
return true;
}
void DFS2(int u) {
c[u]=cur++;
for(int v:g[u]) {
DFS2(v);
}
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
//freopen(Task".inp", "r", stdin);
//freopen(Task".out", "w", stdout);
cin >> n;
rep(i, 1, n) cin >> s1[i];
rep(i, 1, n) {
int u; cin >> u;
s2[i]=s1[u];
}
int leng=s1[1].size();
for(int i=1 ; i<n ; ++i) {
rep(j, 0, leng-1) {
if(s2[i][j]!=s2[i+1][j]) {
int u=s2[i][j]-'a';
int v=s2[i+1][j]-'a';
g[u].push_back(v);
++in[v];
break;
}
}
}
rep(i, 0, 25) {
if(g[i].size()==0||visit[i]) continue;
if(DFS(i)==false) return cout << "NE", 0;
}
rep(i, 0, 25) {
if(!in[i]) DFS2(i);
}
cout << "DA\n";
rep(i, 0, 25) {
cout << (char)(c[i]+'a');
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
504 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
1024 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1152 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1220 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
1368 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
1368 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1388 KB |
Output is correct |
2 |
Incorrect |
2 ms |
1392 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
1396 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1460 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1588 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
1592 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |