# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
83379 | 2018-11-07T13:00:37 Z | wjoao | Cezar (COCI16_cezar) | C++11 | 3 ms | 744 KB |
#include<bits/stdc++.h> #define maxn 500 using namespace std; string entrada[maxn], ordenado[maxn]; int n, ord[maxn], grau[maxn], atual = 'a', mark[maxn], impossivel; char encryption[maxn]; vector<int> g[maxn]; void dfs(int v, int cor){ mark[v] = cor; for(int i = 0; i < g[v].size(); i++){ int u = g[v][i]; if(mark[u] == cor){ impossivel = true; return; }else if(mark[u] == 0){ dfs(u, cor); } } encryption[atual++]=v; } int main(){ cin >> n; for(int i = 0; i < n; i++ ) cin >> entrada[i]; for(int i = 0; i < n; i++ ){ cin >> ord[i]; ord[i]--; ordenado[ord[i]] = entrada[i]; } //for(int i = 0; i < n; i++){ // cout << ordenado[i] << endl; //} for(int i = 1; i < n; i++){ int j = 0; while( j < ordenado[i].size() && j < ordenado[i-1].size() && ordenado[i][j] == ordenado[i-1][j] ) j++; if( j < ordenado[i].size() && j < ordenado[i-1].size()){ g[ordenado[i][j]].push_back(ordenado[i-1][j]); //cout << ordenado[i][j] << " Tem que ser maior que " << ordenado[i-1][j] << endl; } } for(int i = 'a'; i <= 'z'; i++){ if(mark[i] == 0) dfs(i, i); } if(impossivel){ cout << "NE" << endl; }else{ cout << "DA" << endl; for(int i = 'a'; i <= 'z'; i++){ cout << encryption[i]; }cout << endl; } return 0; }
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 | 508 KB | Output is correct |
2 | Incorrect | 2 ms | 508 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 508 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 512 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 540 KB | Output is correct |
2 | Incorrect | 2 ms | 716 KB | Output isn't correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 736 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 744 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 744 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 744 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |