# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1002150 | overwatch9 | Cave (IOI13_cave) | C++17 | 78 ms | 604 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
void exploreCave(int N) {
vector <int> need_to_find;
for (int i = 0; i < N; i++)
need_to_find.push_back(i);
int s[N+1], d[N+1];
int d_inv[N+1]; // the switch that controls door i
for (int i = 0; i < N; i++) {
int query[N+1];
fill(query, query + N + 1, 0);
for (int j = 0; j < i; j++) {
query[d_inv[j]] = s[d_inv[j]];
}
// if (i == 1) {
// cout << "QUERY: ";
// for (int j = 0; j < N; j++)
// cout << query[j] << ' ';
// cout << '\n';
// }
int sz = need_to_find.size();
// keep half of the positions of the remaining
int l = 0, r = sz - 1;
int correct_pos = 0;
int state = 0;
while (l < r) {
int mid = (l + r) / 2;
// if (i == 1) {
// cout << "QUERY: ";
// for (int j = 0; j < N; j++)
// cout << query[j] << ' ';
// cout << '\n';
// }
for (int j = 0; j <= mid; j++)
query[need_to_find[j]] = 1;
// if (i == 1) {
// cout << "QUERY: ";
// for (int j = 0; j < N; j++)
// cout << query[j] << ' ';
// cout << '\n';
// }
int res = tryCombination(query);
// for (int j = 0; j <= mid; j++)
// query[need_to_find[j]] = 0;
// int res2 = tryCombination(query);
// if (i == 0) {
// cout << "RANGE: " << l << ' ' << r << '\n';
// cout << "RES: " << res << ' ' << res2 << ' ' << '\n';
// }
if (res <= i) {
r = mid;
correct_pos = mid;
state = 0;
} else {
l = mid + 1;
}
}
if (state == 2) {
query[need_to_find[l]] = 1;
int res = tryCombination(query);
if (res == -1 || res > i)
state = 1;
else
state = 0;
}
// cout << i << ": " << l << " state: " << state << '\n';
s[need_to_find[l]] = state;
d[need_to_find[l]] = i;
d_inv[i] = need_to_find[l];
need_to_find.erase(need_to_find.begin() + l);
// cout << "MODIFED: ";
// for (auto j : need_to_find)
// cout << j << ' ';
// cout << '\n';
}
answer(s, d);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |