Submission #1093623

#TimeUsernameProblemLanguageResultExecution timeMemory
1093623huyngoUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms604 KiB
#include<bits/stdc++.h> using namespace std; #include "messy.h" // void add_element(std::string x); // bool check_element(std::string x); // void compile_set(); std::vector<int> restore_permutation(int n, int w, int r) { vector<int> perm(n); // add phase auto add = [&](auto self, int l, int r) -> void { if (l == r) return; int m = (l + r) / 2; string s(n, '1'); for (int i = l; i <= r; ++i) s[i] = '0'; for (int i = l; i <= m; ++i) { s[i] = '1'; add_element(s); s[i] = '0'; } self(self, l, (l + r) / 2); self(self, (l + r) / 2 + 1, r); }; add(add, 0, n - 1); compile_set(); auto solve = [&](auto self, int l, int r, vector<int> z) -> void { if (l == r) { perm[z[0]] = l; return; } int m = (l + r) / 2; string s(n, '1'); for (int i : z) s[i] = '0'; vector<int> y; for (int i : z) { s[i] = '1'; if (check_element(s)) y.push_back(i); s[i] = '0'; } vector<int> t; for (int i = 0, j = 0; i < z.size(); ++i) { if (j < y.size() && z[i] == y[j]) ++j; else t.push_back(z[i]); } self(self, l, m, y); self(self, m + 1, r, t); }; vector<int> z(n, 0); iota(z.begin(), z.end(), 0); solve(solve, 0, n - 1, z); return perm; }

Compilation message (stderr)

messy.cpp: In lambda function:
messy.cpp:45:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |         for (int i = 0, j = 0; i < z.size(); ++i) {
      |                                ~~^~~~~~~~~~
messy.cpp: In instantiation of 'restore_permutation(int, int, int)::<lambda(auto:24, int, int, std::vector<int>)> [with auto:24 = restore_permutation(int, int, int)::<lambda(auto:24, int, int, std::vector<int>)>]':
messy.cpp:56:29:   required from here
messy.cpp:45:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
messy.cpp:46:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |             if (j < y.size() && z[i] == y[j])
      |                 ~~^~~~~~~~~~
#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...