이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long double ld;
typedef vector<vector<ll>> vll;
#define FOR(i, a, b) for(int i = a; i < b; i++)
#define ROF(i, a, b) for(int i = a; i >= b; i--)
#define pb push_back
#define ms memset
#define fi first
#define se second
//Binary search
void exploreCave(int N) {
int s[N]; ms(s,0,sizeof(s));
int a[N], b[N]; ms(a,0,sizeof(a)); ms(b,-1,sizeof(b));
FOR(i,0,N){
int pos[N-i]; int cur = 0;
FOR(j,0,N){
if (b[j]==-1){
s[j]=0; pos[cur]=j; cur++;
}
else s[j] = a[j];
}
int com = (tryCombination(s)==i);
int l = 0, r = N-i; int ans;
if (com){
while (r-l>1){
int mid = (l+r)/2;
FOR(j,0,mid) s[pos[j]]=0;
FOR(j,mid,N-i) s[pos[j]]=1;
if (tryCombination(s)==i){
r=mid;
}else{
l=mid;
}
}
ans=l;
}else{
l=-1; r=N-i-1;
while (r-l>1){
int mid = (l+r)/2;
FOR(j,0,mid+1) s[pos[j]]=0;
FOR(j,mid+1,N-i) s[pos[j]]=1;
if (tryCombination(s)==i){
l=mid;
}else{
r=mid;
}
}
ans=r;
}
b[pos[ans]] = i;
a[pos[ans]] = com;
}
answer(a,b);
/* ... */
}
# | 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... |