제출 #231253

#제출 시각아이디문제언어결과실행 시간메모리
231253islingrUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
6 ms640 KiB
#include "messy.h" #include <algorithm> #include <iostream> #include <numeric> #include <vector> using namespace std; #define rep(i, a, b) for (auto i = (a); i < (b); ++i) #define all(x) begin(x), end(x) bool ask(string &s, int i) { s[i] = '1'; bool b = check_element(s); s[i] = '0'; return b; } void add(string &s, int i) { s[i] = '1'; add_element(s); s[i] = '0'; } vector<int> restore_permutation(int n, int _, int __) { for (int sz = n; sz != 1; sz >>= 1) { for (int l = 0; l != n; l += sz) { string s(n, '1'); rep(i, l, l + sz) s[i] = '0'; rep(i, l, l + sz / 2) add(s, i); } } compile_set(); vector<int> p(n); iota(all(p), 0); for (int sz = n; sz != 1; sz >>= 1) { vector<bool> v(n); for (int l = 0; l != n; l += sz) { string s(n, '1'); rep(i, l, l + sz) s[p[i]] = '0'; rep(i, l, l + sz) v[p[i]] = ask(s, p[i]); partition(begin(p) + l, begin(p) + l + sz, [&v](int x) { return v[x]; }); } } vector<int> res(n); rep(i, 0, n) res[p[i]] = i; return res; }
#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...