# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
81494 |
2018-10-25T03:58:08 Z |
ngot23 |
Cezar (COCI16_cezar) |
C++11 |
|
3 ms |
904 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[105], s2[105];
int n, visit[N], in[N], cur, c[N];
bool cycle=0;
void DFS(int u) {
if(cycle) return;
visit[u]=1;
for(int v:g[u]) {
if(visit[v]==0) {
DFS(v);
} else if(visit[v]==1) { cycle=1; return; }
}
visit[u]=2;
}
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;
cycle=0;
DFS(i);
if(cycle) return cout << "NE\n", 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 |
2 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
636 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 |
640 KB |
Output is correct |
2 |
Incorrect |
2 ms |
680 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
724 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 |
2 ms |
724 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 |
744 KB |
Output is correct |
2 |
Incorrect |
2 ms |
904 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
904 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 |
904 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
904 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
904 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |