이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#include "cave.h"
using namespace std;
int n,type[5005],P[5000],oc[5000],C[5000];
int ask(int S[]) {
int x = tryCombination(S);
if (x == -1) x = n;
return x;
}
/*
void get_type (int pos,int A[]) {
int l = 0, r = n - 1;
int x = ask(A);
if (pos <= x) type[pos] = 0,A[pos] = 0;
else type[pos] = 1, A[pos] = 1;
while (l != r) {
int m = (l + r)/2;
for (int i = l; i <= m; i++) if (!oc[i]) A[i]^=1;
int x = ask(A);
if (pos <= x) {
l = m + 1;
}
else r = m;
for (int i = l; i <= m; i++) if (!oc[i]) A[i]^=1;
}
/* if (l == r - 1) {
if (oc[l]) x = r;
else if (oc[r]) x = l;
else {
A[l]^=1;
int t = ask(A);
if (pos <= t) x = r;
else x = l;
A[l]^=1;
}
}
x = l;
oc[x] = 1;
C[x] = type[pos];
P[x] = pos;
} */
void exploreCave(int N) {
n = N;
int A[N];
for (int i =0 ; i < n; i++)
A[i] = 0;
for (int pos = 0;pos < n; pos++) {
int l = 0, r = n - 1;
int x = ask(A);
if (pos <= x) type[pos] = 0,A[pos] = 0;
else type[pos] = 1, A[pos] = 1;
while (l != r) {
int m = (l + r)/2;
for (int i = l; i <= m; i++) if (!oc[i]) A[i]^=1;
int x = ask(A);
if (pos < x) {
l = m + 1;
}
else r = m;
for (int i = l; i <= m; i++) if (!oc[i]) A[i]^=1;
}
/* if (l == r - 1) {
if (oc[l]) x = r;
else if (oc[r]) x = l;
else {
A[l]^=1;
int t = ask(A);
if (pos <= t) x = r;
else x = l;
A[l]^=1;
}
} */
x = l;
oc[x] = 1;
C[x] = type[pos];
P[x] = pos;
}
int S[N],D[N];
for (int i = 0; i < n; i++)
S[i] = C[i],
D[i] = P[i];
answer(S, D);
}
컴파일 시 표준 에러 (stderr) 메시지
cave.cpp:28:1: warning: "/*" within comment [-Wcomment]
/* if (l == r - 1) {
# | 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... |