# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83380 | 2018-11-07T13:07:12 Z | luciocf | Cezar (COCI16_cezar) | C++14 | 4 ms | 596 KB |
#include <bits/stdc++.h> using namespace std; const int maxs = 30; const int maxn = 110; typedef pair<int, string> pii; int grau[maxs], ans[maxs]; pii num[maxn]; vector<int> grafo[maxs]; string s[maxn]; int main(void) { int n; cin >> n; for (int i = 1; i <= n; i++) cin >> num[i].second; for (int i = 1; i <= n; i++) { int x; cin >> x; num[x].first = i; } sort(num+1, num+n+1); for (int i = 1; i <= n; i++) { for (int j = i+1; j <= n; j++) { string s1 = num[i].second, s2 = num[j].second; for (int k = 0; k < min(s1.size(), s2.size()); k++) { if (s1[k] == s2[k]) continue; grafo[s1[k]-'a'].push_back(s2[k]-'a'); grau[s2[k]-'a']++; break; } } } queue<int> fila; for (int i = 0; i < 26; i++) if (!grau[i]) fila.push(i); int atual = 0; while (!fila.empty()) { int x = fila.front(); fila.pop(); ans[x] = atual++; for (auto v: grafo[x]) { grau[v]--; if (!grau[v]) fila.push(v); } } for (int i = 0; i < 26; i++) { if (grau[i]) { cout << "NE\n"; return 0; } } cout << "DA\n"; for (int i = 0; i < 26; i++) cout << (char) (ans[i]+'a'); cout << "\n"; }
Compilation message
# | 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 | 3 ms | 508 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 556 KB | Output is correct |
2 | Incorrect | 2 ms | 556 KB | Output isn't 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 | 3 ms | 556 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 556 KB | Output is correct |
2 | Incorrect | 2 ms | 556 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 556 KB | Output is correct |
2 | Correct | 4 ms | 556 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 596 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 596 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 596 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |