Submission #83378

#TimeUsernameProblemLanguageResultExecution timeMemory
83378wjoaoCezar (COCI16_cezar)C++11
0 / 100
3 ms1112 KiB
#include<bits/stdc++.h> #define maxn 110 using namespace std; string entrada[maxn], ordenado[maxn]; int n, ord[maxn], grau[500], atual = 'a', mark[500], impossivel; char encryption[300]; vector<int> g[300]; 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; cout << (char)v << " achou " << (char) u << endl; 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 (stderr)

cezar.cpp: In function 'void dfs(int, int)':
cezar.cpp:14:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int i = 0; i < g[v].size(); i++){
                  ~~^~~~~~~~~~~~~
cezar.cpp: In function 'int main()':
cezar.cpp:42:14: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while( j < ordenado[i].size() && j < ordenado[i-1].size() && ordenado[i][j] == ordenado[i-1][j] ) j++;
            ~~^~~~~~~~~~~~~~~~~~~~
cezar.cpp:42:40: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     while( j < ordenado[i].size() && j < ordenado[i-1].size() && ordenado[i][j] == ordenado[i-1][j] ) j++;
                                      ~~^~~~~~~~~~~~~~~~~~~~~~
cezar.cpp:43:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if( j < ordenado[i].size() && j < ordenado[i-1].size()){
         ~~^~~~~~~~~~~~~~~~~~~~
cezar.cpp:43:37: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if( j < ordenado[i].size() && j < ordenado[i-1].size()){
                                   ~~^~~~~~~~~~~~~~~~~~~~~~
cezar.cpp:44:23: warning: array subscript has type 'char' [-Wchar-subscripts]
       g[ordenado[i][j]].push_back(ordenado[i-1][j]);
                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...