Submission #668342

#TimeUsernameProblemLanguageResultExecution timeMemory
668342vjudge1Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms468 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; void insert_all(int n, int j, string mask) { if (n == 1) return; string mask1(mask.begin(), mask.end()), mask2(mask.begin(), mask.end()); for (int i = j; i < j + n / 2; i++) { string s(mask.begin(), mask.end()); s[i] = '1'; add_element(s); mask2[i] = '1'; } for (int i = j + n / 2; i < j + n; i++) mask1[i] = '1'; insert_all(n / 2, j, mask1); insert_all(n / 2, j + n / 2, mask2); } void retrieve_permutation(int n, int j, string mask, vector<int> &p) { if (n == 1) { for (int i = 0; i < mask.size(); i++) if (mask[i] == '0') { p[i] = j; return; } } string mask1(mask.begin(), mask.end()), mask2(mask.begin(), mask.end()); for (int i = 0; i < mask.size(); i++) { if (mask[i] == '0') { string s(mask.begin(), mask.end()); s[i] = '1'; if (check_element(s)) mask2[i] = '1'; else mask1[i] = '1'; } } retrieve_permutation(n / 2, j, mask1, p); retrieve_permutation(n / 2, j + n / 2, mask2, p); } std::vector<int> restore_permutation(int n, int w, int r) { string mask; for (int i = 0; i < n; i++) mask.push_back('0'); insert_all(n, 0, mask); compile_set(); vector<int> p(n); retrieve_permutation(n, 0, mask, p); return p; // }

Compilation message (stderr)

messy.cpp: In function 'void retrieve_permutation(int, int, std::string, std::vector<int>&)':
messy.cpp:31:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |         for (int i = 0; i < mask.size(); i++)
      |                         ~~^~~~~~~~~~~~~
messy.cpp:41:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     for (int i = 0; i < mask.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...