Submission #500881

#TimeUsernameProblemLanguageResultExecution timeMemory
500881aryan12Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms460 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; vector<int> ans(129); void Input(int l, int r, int n) { if(l == r) { return; } string s = ""; for(int i = 0; i < n; i++) { s += "1"; } for(int i = l; i <= r; i++) { s[i] = '0'; } int mid = (l + r) / 2; for(int i = l; i <= mid; i++) { s[i] = '1'; add_element(s); s[i] = '0'; } Input(l, mid, n); Input(mid + 1, r, n); } void Output(int l, int r, int n, vector<int> possible) { if(l == r) { ans[possible[0]] = l; return; } string s = ""; for(int i = 0; i < n; i++) { s += "1"; } for(int i = 0; i < possible.size(); i++) { s[possible[i]] = '0'; } int mid = (l + r) / 2; vector<int> left, right; for(int i = 0; i < possible.size(); i++) { s[possible[i]] = '1'; if(check_element(s)) { left.push_back(possible[i]); } else { right.push_back(possible[i]); } s[possible[i]] = '0'; } /*cout << "L = " << l << ", R = " << r << "\n"; cout << "left:\n"; for(int i = 0; i < left.size(); i++) { cout << left[i] << " "; } cout << "\nright:\n"; for(int i = 0; i < right.size(); i++) { cout << right[i] << " "; } cout << "\n";*/ Output(l, mid, n, left); Output(mid + 1, r, n, right); } vector<int> restore_permutation(int n, int w, int r) { Input(0, n - 1, n); ans.resize(n); compile_set(); vector<int> possible; for(int i = 0; i < n; i++) { possible.push_back(i); } Output(0, n - 1, n, possible); return ans; }

Compilation message (stderr)

messy.cpp: In function 'void Output(int, int, int, std::vector<int>)':
messy.cpp:37:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     for(int i = 0; i < possible.size(); i++) {
      |                    ~~^~~~~~~~~~~~~~~~~
messy.cpp:42:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     for(int i = 0; i < possible.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...