# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
432138 | MilosMilutinovic | Cave (IOI13_cave) | C++14 | 1063 ms | 580 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
int tryCombination(int S[]);
void answer(int S[], int D[]);
void exploreCave(int N) {
int combination[N];
for (int i = 0; i < N; i++)
combination[i] = 0;
bool locked[N];
for (int i = 0; i < N; i++)
locked[i] = false;
int position[N];
for (int i = 0; i < N; i++) {
vector<int> positions;
for (int j = 0; j < N; j++)
if (!locked[j])
positions.push_back(j);
int current = tryCombination(combination);
bool is_correct = (current == -1 || current > i);
if (!is_correct) {
assert(current == i);
int bot = 0, top = (int) positions.size() - 1, pos = -1;
while (bot <= top) {
int mid = bot + top >> 1;
for (int j = 0; j <= mid; j++)
combination[positions[j]] ^= 1;
int value = tryCombination(combination);
if (value == -1 || value > i)
pos = mid, top = mid - 1;
else
bot = mid + 1;
for (int j = 0; j <= mid; j++)
combination[positions[j]] ^= 1;
}
assert(pos != -1);
combination[positions[pos]] = 1;
locked[positions[pos]] = true;
position[positions[pos]] = i;
} else {
int bot = 0, top = (int) positions.size() - 1, pos = -1;
while (bot <= top) {
int mid = bot + top >> 1;
for (int j = 0; j <= mid; j++)
combination[positions[j]] ^= 1;
int value = tryCombination(combination);
if (value == i)
pos = mid, top = mid - 1;
else
bot = mid + 1;
for (int j = 0; j <= mid; j++)
combination[positions[j]] ^= 1;
}
assert(pos != -1);
locked[positions[pos]] = true;
position[positions[pos]] = i;
}
}
answer(combination, position);
}
컴파일 시 표준 에러 (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... |