이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "cave.h"
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 2e5 + 2;
const int M = 5e5 + 2;
int mod = 1000000007;
int tryCombination(int S[]);
void answer(int S[], int D[]);
void exploreCave(int n) {
int ans[n];
int sw[n];
for (int i = 0; i < n; i++) ans[i] = sw[i] = -1;
for (int i = 0; i < n; i++) {
int tmp[n];
for (int j = 0; j < n; j++) {
if (sw[j] == -1) tmp[j] = 0;
else tmp[j] = sw[j];
}
int x = (tryCombination(tmp) == i);
int l = 0, r = n - 1;
while (l < r) {
int mid = l + r >> 1;
for (int j = 0; j <= mid; j++) {
if (sw[j] == -1) tmp[j] = 1;
}
int y = (tryCombination(tmp) == i);
if (x == y) l = mid + 1;
else r = mid;
for (int j = 0; j <= mid; j++) {
if (sw[j] == -1) tmp[j] = 0;
}
}
sw[l] = x;
ans[l] = i;
}
answer(sw, ans);
}
컴파일 시 표준 에러 (stderr) 메시지
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:28:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
28 | int mid = 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... |