Submission #206548

#TimeUsernameProblemLanguageResultExecution timeMemory
206548spdskatrUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
9 ms632 KiB
#include <vector> #include <string> #include <cstring> #include "messy.h" using namespace std; int N; vector<int> perm; void rec(int l, int r) { if (l == r) return; int mid = (l + r)/2; for (int i = l; i <= mid; i++) { string s; for (int j = 0; j < N; j++) { if (j < l || j > r || j == i) s.push_back('1'); else s.push_back('0'); } add_element(s); } rec(l, mid); rec(mid+1, r); } void reb(int l, int r, vector<int> &elems) { if (l == r) { perm[elems[0]] = l; return; } vector<int> lv, rv; int pos[128]; memset(pos, 0, sizeof(pos)); for (int i = 0; i < elems.size(); i++) pos[elems[i]] = 1; for (int i = 0; i < elems.size(); i++) { string s; for (int j = 0; j < N; j++) { if (pos[j] == 0 || j == elems[i]) s.push_back('1'); else s.push_back('0'); } if (check_element(s)) { lv.push_back(elems[i]); } else { rv.push_back(elems[i]); } } int mid = (l + r) / 2; reb(l, mid, lv); reb(mid+1, r, rv); } std::vector<int> restore_permutation(int n, int w, int r) { N = n; rec(0, n-1); compile_set(); vector<int> inds; for (int i = 0; i < N; i++) inds.push_back(i); for (int i = 0; i < N; i++) perm.push_back(0); reb(0, n-1, inds); return perm; }

Compilation message (stderr)

messy.cpp: In function 'void reb(int, int, std::vector<int>&)':
messy.cpp:33:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < elems.size(); i++) pos[elems[i]] = 1;
                  ~~^~~~~~~~~~~~~~
messy.cpp:34:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < elems.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...