# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88126 | 2018-12-03T21:41:04 Z | jasony123123 | Cezar (COCI16_cezar) | C++11 | 2 ms | 556 KB |
#include <stdio.h> #include <queue> using namespace std; int N,P[111]; char S[111][111],ans[30]; bool f[26][26]; int d[26]; int main() { scanf ("%d",&N); for (int i=1;i<=N;i++) scanf ("%s",S[i]); for (int i=1;i<=N;i++) scanf ("%d",&P[i]); bool good = 1; for (int i=2;i<=N;i++){ for (int j=0;;j++){ if (S[P[i-1]][j] == 0) break; if (S[P[i]][j] == 0) good = 0; if (S[P[i-1]][j] != S[P[i]][j]){ f[S[P[i-1]][j]-'a'][S[P[i]][j]-'a'] = 1; break; } } } for (int i=0;i<26;i++) for (int j=0;j<26;j++) if (f[i][j]) d[j]++; queue<int> Q; for (int i=0;i<26;i++) if (d[i] == 0) Q.push(i); int c = 0; while (!Q.empty()){ int x = Q.front(); Q.pop(); ans[x] = c + 'a'; c++; for (int y=0;y<26;y++) if (f[x][y]){ if (--d[y] == 0) Q.push(y); } } if (c < 26) good = 0; if (good){ puts("DA"); puts(ans); } else{ puts("NE"); } return 0; }
Compilation message
# | 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 | 500 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 500 KB | Output is correct |
2 | Correct | 2 ms | 500 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 500 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 520 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 520 KB | Output is correct |
2 | Correct | 2 ms | 520 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 520 KB | Output is correct |
2 | Correct | 2 ms | 556 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 556 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 556 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 556 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |