제출 #777712

#제출 시각아이디문제언어결과실행 시간메모리
777712AkibAzmain동굴 (IOI13_cave)C++17
100 / 100
197 ms432 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; void exploreCave (int n) { //// subtask 1 // vector < int > a (n), b (n); // for (int i = tryCombination (a.data ()); i != -1; i = tryCombination (a.data ())) // a[i] = !a[i]; // for (int i = 0; i < n; ++i) b[i] = i; // answer (a.data (), b.data ()); //// subtask 2 // vector < int > a (n), b (n); // for (int i = 0; i < n; ++i) // { // a[i] = 1; // b[i] = tryCombination (&a[0]); // a[i] = 0; // } // answer (&a[0], &b[0]); //// subtask 3 // vector < int > a (n), b (n, -1); // for (int i = tryCombination (&a[0]); i != -1;) // { // for (int j = 0; j < n; ++j) // { // if (b[j] != -1) continue; // a[j] = !a[j]; // int s = tryCombination (&a[0]); // if (s < i && s != -1) b[j] = s, a[j] = !a[j]; // if (s > i || s == -1) // { // b[j] = i; // i = s; // break; // } // } // } // for (int i = 0; i < n; ++i) // { // if (b[i] >= 0) continue; // a[i] = !a[i]; // b[i] = tryCombination (&a[0]); // a[i] = !a[i]; // } // answer (&a[0], &b[0]); /// full task int s = -2; vector < int > a (n), b (n, -1); for (int i = 0; i < n; ++i) { if (s == -2) s = tryCombination (&a[0]); int l = 0, r = n; while (l < r) { if (l + 1 == r) break; int m = (l + r) / 2; for (int j = l; j < m; ++j) if (b[j] == -1) a[j] = !a[j]; int t = tryCombination (&a[0]); for (int j = l; j < m; ++j) if (b[j] == -1) a[j] = !a[j]; if ((s == i && (t > i || t == -1)) || ((s > i || s == -1) && t == i)) r = m; else l = m; } b[l] = i; if (s == i) a[l] = !a[l], s = -2; } answer (&a[0], &b[0]); }
#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...