# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83433 | 2018-11-07T14:47:05 Z | Leonardo_Paes | Cezar (COCI16_cezar) | C++11 | 4 ms | 672 KB |
#include <bits/stdc++.h> using namespace std; typedef pair<int,string> pis; #define MAXN 110 pis vet[MAXN]; int mat[26][26], mark[26]; stack<int> pilha; void dfs(int u){ mark[u]=1; for(int i=0; i<=25; i++){ if(mat[u][i]==1 and mark[i]==0){ dfs(i); } } pilha.push(u); } int main(){ int n; cin >> n; for(int i=1; i<=n; i++){ cin >> vet[i].second; } for(int i=1; i<=n; i++){ cin >> vet[i].first; } sort(vet+1, vet+n+1); for(int i=1; i<n; i++){ for(int j=i+1; j<=n; j++){ string a = vet[i].second; string b = vet[j].second; int siz = max(a.size(), b.size()); for(int k=0; k<siz; k++){ if(k+1==a.size() or k+1==b.size()){ break; } if(a[k] != b[k]){ mat[b[k]-'a'][a[k]-'a'] = 1; break; } } } } for(int i=0; i<=25; i++){ for(int j=0; j<=25; j++){ if(mat[i][j]==1 and mat[j][i]==1){ cout << "NE" << endl; return 0; } } } cout << "DA" << endl; for(int i=0; i<=25; i++){ if(mark[i]==0){ dfs(i); stack<int> pilha2; while(!pilha.empty()){ pilha2.push(pilha.top()); pilha.pop(); } while(!pilha2.empty()){ cout << char(pilha2.top() + (int)'a'); pilha2.pop(); } } } return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 380 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 512 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 512 KB | Output is correct |
2 | Incorrect | 3 ms | 512 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 512 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 584 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 600 KB | Output is correct |
2 | Incorrect | 3 ms | 624 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 4 ms | 652 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 652 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 652 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 672 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |