제출 #536614

#제출 시각아이디문제언어결과실행 시간메모리
536614timreizin동굴 (IOI13_cave)C++17
100 / 100
218 ms476 KiB
#include "cave.h" #include <vector> #include <numeric> #include <iostream> using namespace std; void exploreCave(int n) { int s[n], d[n]; vector<int> left(n); iota(left.begin(), left.end(), 0); for (int i = 0; i < n; ++i) { for (int j : left) s[j] = 0; int res = tryCombination(s); if (res == -1) res = n + 1; if (res >= i + 1) { int l = 0, r = (int)left.size() - 1; while (l != r) { int m = (l + r) >> 1; for (int j = l; j <= r; ++j) s[left[j]] = j > m; res = tryCombination(s); if (res == -1) res = n + 1; if (res >= i + 1) r = m; else l = m + 1; } d[i] = left[l]; left.erase(left.begin() + l); s[d[i]] = 0; } else { int l = 0, r = (int)left.size() - 1; while (l != r) { int m = (l + r) >> 1; for (int j = l; j <= r; ++j) s[left[j]] = j <= m; res = tryCombination(s); if (res == -1) res = n + 1; if (res >= i + 1) r = m; else l = m + 1; } d[i] = left[l]; left.erase(left.begin() + l); s[d[i]] = 1; } } int nd[n]; for (int j = 0; j < n; ++j) nd[d[j]] = j; answer(s, nd); }
#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...