제출 #590948

#제출 시각아이디문제언어결과실행 시간메모리
590948JosiaUnscrambling a Messy Bug (IOI16_messy)C++14
0 / 100
12 ms676 KiB
#include <vector> #include <bits/stdc++.h> #include "messy.h" using namespace std; void ADDELEM(vector<bool> a) { string s; for (bool i: a) { if (i) s.push_back('1'); else s.push_back('0'); } cerr << "added: " << s << "\n"; add_element(s); } bool CHECKELEM(vector<bool> a) { string s; for (bool i: a) { if (i) s.push_back('1'); else s.push_back('0'); } bool res = check_element(s); cerr << "checked: " << s << ": " << (int)res << "\n"; return res; } std::vector<int> restore_permutation(int n, int w, int r) { int l = log2(n); vector<bool> mask(n, 0); for (int i = l-1; i>=0; i--) { vector<bool> add = mask; // if (i == 0) { // for (int j = 0; j<n; j++) add[j] = !add[j]; // } for (int j = 0; j<n; j++) { if ((j & (1<<i)) == 0) { add[j] = !add[j]; mask[j] = 1; ADDELEM(add); add[j] = !add[j]; } } } vector<bool> lastOne(n, 0); lastOne[0] = 1; lastOne[n-3] = 1; compile_set(); vector<int> res(n); mask.assign(n, 0); for (int i = l-1; i>=0; i--) { vector<bool> add = mask; // if (i == 0) { // for (int j = 0; j<n; j++) add[j] = !add[j]; // } for (int j = 0; j<n; j++) { add[j] = !add[j]; int tmpResp = CHECKELEM(add); add[j] = !add[j]; if (tmpResp) { mask[j] = 1; } else { res[j] += 1<<i; } } } int indexOfFirst; for (int i = 0; i<n; i++) { if(res[i] == 0) { indexOfFirst = i; } } vector<int> badIndicies; for (int i = 0; i<n; i++) { if(res[i] == n-4) { badIndicies.push_back(i); } } cerr << badIndicies.size() << "\n"; assert(badIndicies.size() == 2); vector<bool> ask(n, 0); ask[indexOfFirst] = 1; ask[badIndicies[0]] = 1; if (CHECKELEM(ask)) res[badIndicies[0]]++; else res[badIndicies[1]]++; 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...