# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
171678 | 2019-12-29T22:48:27 Z | Tuk1352 | Cezar (COCI16_cezar) | C++11 | 3 ms | 396 KB |
#include <bits/stdc++.h> using namespace std; int main() { int n, la, lb, t=0, a, b; cin >> n; string S[n], s[n]; int A[n], K[27]; vector <int> D[27], T; char c1, c2, c[26]; for (int i = 0; i < 27; i++) { K[i] = 0; } for (int i = 0; i < n; i++) { cin >> S[i]; } for (int i = 0; i < n; i++) { cin >> A[i]; s[i] = S[A[i]-1]; } for (int i = 1; i < n; i++) { la = s[i-1].length(); lb = s[i].length(); int g = 1; for (int y = 0; y < min(la,lb); y++) { if (s[i-1][y] != s[i][y]) { g = 0; c1 = s[i-1][y]; c2 = s[i][y]; a = c1 - 'a'; b = c2 - 'a'; D[a].push_back(b); K[b]++; break; } } if (g == 1 && la > lb) { cout << "NE"; return 0; } } for (int i = 0; i < 26; i++) { if (K[i] == 0) { t++; c1 = 'a'+t-1; c[i] = c1; T.push_back(i); } } for (int i = 0; i < T.size(); i++) { a = T[i]; for (int y = 0; y < D[a].size(); y++) { b = D[a][y]; K[b]--; if (K[b] == 0) { t++; c1 = 'a'+t-1; c[b] = c1; T.push_back(b); } } } if (t != 26) { cout << "NE"; return 0; } cout << "DA" << "\n"; for (int i = 0; i < 26; i++) { cout << c[i]; } 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 | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 396 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 356 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 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 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 376 KB | Output is correct |
2 | Correct | 3 ms | 376 KB | Output is correct |
# | 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 | 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 | 376 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |