제출 #592178

#제출 시각아이디문제언어결과실행 시간메모리
592178EliasUnscrambling a Messy Bug (IOI16_messy)C++17
0 / 100
1 ms340 KiB
#include <bits/stdc++.h> using namespace std; int n; vector<int> p; vector<set<int>> inside; #ifndef _DEBUG #include "messy.h" #endif #ifdef _DEBUG void add_element(string s) { cout << s << "\n"; } bool check_element(string s) { cout << s << "\n"; bool b; cin >> b; return b; } void compile_set() { cout << "-------------------\n"; } #endif void segAdd(int l, int r, int i) { if (l + 1 == r) return; int m = l + (r - l) / 2; string s(n, '0'); for (int i = 0; i < n; i++) s[i] = ((i >= l && i < r) ? '0' : '1'); for (int i = l; i < m; i++) { string out = s; out[i] = '1'; add_element(out); } segAdd(l, m, i * 2 + 1); segAdd(m, r, i * 2 + 2); } void segGet(int l, int r, int i) { if (l + 1 == r) { p[*(inside[i].begin())] = l; return; } string s(n, '0'); for (int j = 0; j < n; j++) if (!inside[i].count(j)) s[j] = '1'; for (int val : inside[i]) { string query = s; query[val] = '1'; if (check_element(query)) inside[i * 2 + 1].insert(val); else inside[i * 2 + 2].insert(val); } int m = l + (r - l) / 2; segGet(l, m, i * 2 + 1); segGet(m, r, i * 2 + 2); } vector<int> restore_permutation(int N, int w, int r) { n = N; p = vector<int>(n); segAdd(0, n, 0); inside = vector<set<int>>(n * 4); for (int i = 0; i < n; i++) inside[0].insert(i); segGet(0, n, 0); return p; } #ifdef _DEBUG int main() { int n, w, r; cin >> n >> w >> r; restore_permutation(n, w, r); } #endif
#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...