이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz size()
#define all(x) x.begin(), x.end()
#define F first
#define S second
typedef pair < int, int > pii;
typedef vector < int > vi;
typedef vector < vi > vvi;
void exploreCave (int n) {
int ask[n];
int good[n];
int d[n];
for (int i = 0; i < n; i++) {
good[i] = d[i] = -1;
}
// vector<int> good(n, -1), d(n, -1);
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
if (good[j] != -1) {
ask[j] = 0;
}
else {
ask[j] = good[j];
}
}
int x = tryCombination(ask);
if (x == i) {
for (int j = 0; j < n; j++) {
if (good[j] != -1) {
ask[j] = 1;
}
else {
ask[j] = good[j];
}
}
}
int l = 0, r = n - 1;
while (r - l > 1) {
int mid = (l + r) / 2;
for (int j = l; j < mid; j++) {
if (good[j] != -1) {
ask[j] = 1 - ask[j];
}
else {
ask[j] = good[j];
}
}
x = tryCombination(ask);
if (x == i) {
for (int j = l; j < mid; j++) {
if (good[j] != -1) {
ask[j] = 1 - ask[j];
}
else {
ask[j] = good[j];
}
}
for (int j = mid; j <= r; j++) {
if (good[j] != -1) {
ask[j] = 1 - ask[j];
}
else {
ask[j] = good[j];
}
}
r = mid - 1;
}
else {
l = mid;
}
}
if (good[l] != -1) {
ask[l] = 1 - ask[l];
}
else {
ask[l] = good[l];
}
x = tryCombination(ask);
if (x == i) {
if (good[l] != -1) {
ask[l] = 1 - ask[l];
}
else {
ask[l] = good[l];
}
l = r;
}
good[i] = ask[l];
d[i] = l;
}
answer(good, d);
}
/*
signed main() {
vi a;
a.pb(-2);
a.pb(2);
a.pb(2);
a.pb(-2);
a.pb(-2);
a.pb(2);
cout << count_swaps(a);
}
*/
# | 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... |