# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1075410 | Ignut | 동굴 (IOI13_cave) | C++17 | 181 ms | 856 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
// Ignut
#include <bits/stdc++.h>
#include "cave.h"
using namespace std;
int tryCombination(int S[]);
void answer(int S[], int D[]);
int NN;
int Ask(int S[]) {
int ask = tryCombination(S);
if (ask == -1) return NN;
return ask;
}
void exploreCave(int N) {
NN = N;
int door[N];
int sw[N] = {};
vector<int> possible;
for (int i = 0; i < N; i ++) possible.push_back(i);
bool used[N] = {};
int cntKnow = 0;
while (cntKnow < N) {
int ask0 = Ask(sw);
/*if (ask == -1) {
cntKnow = N; break;
}*/
// cout << cntKnow << " : " << ask0 << '\n';
// for (int val : possible) cout << val << '_';
// cout << '\n';
if (ask0 == cntKnow) {
// nextVal is 1
int lo = 0, hi = possible.size() - 1;
while (lo < hi) {
int mid = lo + (hi - lo) / 2;
for (int i = lo; i <= mid; i ++) sw[possible[i]] ^= 1;
int ask = Ask(sw);
// cout << " -- " << mid << " -- " << ask << '\n';
for (int i = lo; i <= mid; i ++) sw[possible[i]] ^= 1;
if (ask == ask0)
lo = mid + 1;
else
hi = mid;
}
sw[possible[lo]] ^= 1;
door[possible[lo]] = cntKnow;
vector<int> next_possible;
for (int i = 0; i < possible.size(); i ++) if (i != lo) next_possible.push_back(possible[i]);
possible = next_possible;
}
else {
// nextVal is 0
int lo = 0, hi = possible.size() - 1;
while (lo < hi) {
int mid = lo + (hi - lo) / 2;
for (int i = lo; i <= mid; i ++) sw[possible[i]] ^= 1;
int ask = Ask(sw);
for (int i = lo; i <= mid; i ++) sw[possible[i]] ^= 1;
if (ask == cntKnow)
hi = mid;
else
lo = mid + 1;
}
door[possible[lo]] = cntKnow;
vector<int> next_possible;
for (int i = 0; i < possible.size(); i ++) if (i != lo) next_possible.push_back(possible[i]);
possible = next_possible;
}
cntKnow ++;
}
// for (int i = 0; i < N; i ++) sw[i] ^= 1;
answer(sw, door);
return;
}
컴파일 시 표준 에러 (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... |