Submission #879664

#TimeUsernameProblemLanguageResultExecution timeMemory
879664StefanL2005Unscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms856 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; /* void add_element(string s) { cout<< "Added " << s << "\n"; } void compile_set() { cout<< "COMPILING SETS" << "\n"; } bool check_element(string s) { cout<< "Checking " << s << "\n"; int ans; cin>> ans; return ans; } */ void AddRecursive(int p1, int p2, string bit) { if (p2 - p1 == 1) { bit.replace(0, bit.length(), bit.length(), '1'); bit[p1] = '0'; add_element(bit); return; } if (p1 - 1 >= 0) bit.replace(0, p1, p1, '1'); if (p2 + 1 < bit.length()) bit.replace(p2 + 1, (bit.length() - p2 - 1), (bit.length() - p2 - 1), '1'); int m = (p1 + p2) >> 1; for (int i = p1; i <= m; i++) { bit[i] = '1'; add_element(bit); bit[i] = '0'; } AddRecursive(p1, m, bit); AddRecursive(m + 1, p2, bit); } void CheckRecursive(int p1, int p2, string bit, vector<int> &CheckBit, vector<int> &result) { bit.assign(bit.length(), '1'); for (int i = 0; i < CheckBit.size(); i++) bit[CheckBit[i]] = '0'; if (p2 - p1 == 1) { bit[CheckBit[0]] = '1'; if (check_element(bit)) { result[CheckBit[1]] = p1; result[CheckBit[0]] = p2; } else { result[CheckBit[1]] = p2; result[CheckBit[0]] = p1; } return; } vector<int> BotHalf, TopHalf; for (int i = 0; i < CheckBit.size(); i++) { bit[CheckBit[i]] = '1'; if (check_element(bit)) BotHalf.push_back(CheckBit[i]); else TopHalf.push_back(CheckBit[i]); bit[CheckBit[i]] = '0'; } int m = (p1 + p2) >> 1; CheckRecursive(p1, m, bit, BotHalf, result); CheckRecursive(m + 1, p2, bit, TopHalf, result); } vector<int> restore_permutation(int n, int w, int r) { string bit, use; bit.assign(n, '0'); AddRecursive(0, n - 1, bit); compile_set(); vector<int> CheckBit(n); vector<int> result(n); for (int i = 0; i < n; i++) CheckBit[i] = i; CheckRecursive(0, n - 1, bit, CheckBit, result); return result; }

Compilation message (stderr)

messy.cpp: In function 'void AddRecursive(int, int, std::string)':
messy.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     if (p2 + 1 < bit.length())
      |         ~~~~~~~^~~~~~~~~~~~~~
messy.cpp: In function 'void CheckRecursive(int, int, std::string, std::vector<int>&, std::vector<int>&)':
messy.cpp:53:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   53 |     for (int i = 0; i < CheckBit.size(); i++)
      |                     ~~^~~~~~~~~~~~~~~~~
messy.cpp:75:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   75 |     for (int i = 0; i < CheckBit.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...