Submission #95678

#TimeUsernameProblemLanguageResultExecution timeMemory
95678tqbfjotldUnscrambling a Messy Bug (IOI16_messy)C++14
38 / 100
7 ms460 KiB
#include "messy.h" #include <vector> #include <string> using namespace std; bool visited[129]; vector<int> adjl[129]; int c = 0; int ans[129]; void dfs(int node){ ans[node] = c; c++; visited[node]=true; for (int x = 0; x<adjl[node].size(); x++){ if (!visited[adjl[node][x]]){ dfs(adjl[node][x]); } } } std::vector<int> restore_permutation(int n, int w, int r) { vector<string> original; for (int x = 0; x<n-1; x++){ string s = ""; for(int y = 0; y<n; y++){ if (y==x||y==x+1){ s+="1"; } else s+="0"; } add_element(s); } string k = "1"; for (int x = 0; x<n-1; x++){ k+="0"; } add_element(k); compile_set(); for (int x = 0; x<n; x++){ for (int y = x+1; y<n; y++){ k = ""; for (int z = 0; z<n; z++){ if (z==x||z==y) k+="1"; else k+="0"; } if (check_element(k)){ adjl[x].push_back(y); adjl[y].push_back(x); } } } int start; for (int x = 0; x<n; x++){ k = ""; for (int z = 0; z<n; z++){ if (z==x) k+="1"; else k+="0"; } if (check_element(k)){ start = x; } } dfs(start); vector<int> vans; for (int x = 0; x<n; x++){ vans.push_back(ans[x]); } return vans; }

Compilation message (stderr)

messy.cpp: In function 'void dfs(int)':
messy.cpp:13:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int x = 0; x<adjl[node].size(); x++){
                     ~^~~~~~~~~~~~~~~~~~
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:64:8: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
     dfs(start);
     ~~~^~~~~~~
#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...