이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <utility>
#include <set>
#include <cmath>
#include <climits>
#include <cstring>
#include "cave.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<ll, ll> ii;
int ask(int n, int pitaj[], int x[], int odg, int beg, int mid, int end){
if (odg)
beg = mid + 1;
else
end = mid;
for (int i = beg; i <= end; i++){
if (x[i] == -1)
pitaj[i] = 0;
}
return tryCombination(pitaj);
}
void exploreCave(int n){
int x[n];
int curr = 0, curr2 = n - 1;
int pitaj[n];
for (int i = 0; i < n; i++){
pitaj[i] = 1;
x[i] = -1;
}
for (int i = 0; i < n; i++){
int beg = curr, end = curr2, odg = 0;
if (tryCombination(pitaj) >= i)
odg = 1;
while(beg < end){
int mid = (beg + end)/2;
if (ask(n, pitaj, x, odg, beg, mid, end) > i)
end = mid;
else
beg = mid + 1;
}
x[beg] = i;
pitaj[beg] = odg;
if (beg == curr)
curr = beg + 1;
if (beg == curr2)
curr2 = beg - 1;
}
answer(pitaj, x);
}
# | 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... |