Submission #65319

#TimeUsernameProblemLanguageResultExecution timeMemory
65319zubecUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
4 ms512 KiB
#include <bits/stdc++.h> using namespace std; #include "messy.h" vector <int> ansvec; int n, cnt; void solve(int l, int r){ string s; if (l == r) return; for (int i = 0; i < n; i++){ s += '1'; } for (int i = l-1; i < r; i++){ s[i] = '0'; } int mid = (l+r)>>1; for (int i = l-1; i < mid; i++){ s[i] = '1'; add_element(s); s[i] = '0'; } solve(l, mid); solve(mid+1, r); } void solve2(vector <int> vec){ string s; if (vec.size() == 1){ ansvec[vec[0]] = cnt++; return; } for (int i = 0; i < n; i++){ s += '1'; } for (int i = 0; i < vec.size(); i++){ s[vec[i]] = '0'; } vector <int> vec1, vec2; for (int i = 0; i < vec.size(); i++){ s[vec[i]] = '1'; if (check_element(s)){ vec1.push_back(vec[i]); } else vec2.push_back(vec[i]); s[vec[i]] = '0'; } solve2(vec1); solve2(vec2); } std::vector<int> restore_permutation(int n, int w, int r) { vector <int> poses; ::n = n; ansvec.resize(n); for (int i = 0; i < n; i++) poses.push_back(i); solve(1, n); compile_set(); solve2(poses); return ansvec; }

Compilation message (stderr)

messy.cpp: In function 'void solve2(std::vector<int>)':
messy.cpp:39:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < vec.size(); i++){
                     ~~^~~~~~~~~~~~
messy.cpp:43:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < vec.size(); i++){
                     ~~^~~~~~~~~~~~
#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...