이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vc vector
typedef vc<ll> vcll;
#define pr pair
typedef pr<ll, ll> prll;
#define f0r(i,a,n) for (i=a; i<n; i++)
#define f1r(i,a,n) for (i=a; i<=n; i++)
#define r0f(i,n,a) for (i=n; i>a; i--)
#define r1f(i,n,a) for (i=n; i>=a; i--)
#define pb push_back
#define mp make_pair
#define INF (LLONG_MAX>>4ll)
#define mxN 5010ll
ll n;
int bar[mxN];
int gar[mxN];
int perm[mxN];
void exploreCave(int N)
{
n=N;
ll i2;
f0r(i2,0,n)
{
bar[i2]=0;
perm[i2]=-1;
gar[i2]=-1;
}
f0r(i2,0,n)
{
ll i3;
f0r(i3, 0, n) if (gar[i3]==-1) bar[i3]=0;
ll i = tryCombination(bar);
/*
// printf("try combination(");
f0r(i3,0,n) printf("%lli ", (ll)bar[i3]);
printf("): ");
scanf("%lli", &i);
*/
if (i==-1) break;
ll j;
ll l=0, r=n-1; // both incl.
bool broke=0;
while (l<r)
{
ll m;
m = ((l+1==r) ? l : (l+r)/2);
// printf("l: %lli, m: %lli, r: %lli\n", l, m, r);
f1r(i3, l, m) if (gar[i3]==-1) bar[i3]^=1;
j = tryCombination(bar);
/*
printf("try combination(");
f0r(i3,0,n) printf("%lli ", (ll)bar[i3]);
printf("): ");
scanf("%lli", &j);
*/
if (j==-1)
{
broke=1;
break;
}
if (j<i)
{
i=j;
r=m;
}
else if (j==i)
{
l=m+1;
}
else
{
f1r(i3, l, m) if (gar[i3]==-1) bar[i3]^=1;
l=m+1;
}
}
if (broke) break;
bar[l]^=1;
gar[l]=bar[l];
// printf("gar[%lli]: %lli\n", l, (ll)gar[l]);
perm[l]=i;
// printf("perm[%lli]: %lli\n", l, (ll)perm[l]);
// printf("\n");
}
f0r(i2,0,n)
{
gar[i2]=bar[i2];
bar[i2]^=1;
ll i;
i = tryCombination(bar);
/*
printf("try combination(");
ll i3;
f0r(i3,0,n) printf("%lli ", (ll)bar[i3]);
printf("): ");
scanf("%lli", &i);
*/
bar[i2]^=1;
perm[i2]=i;
}
// ll i;
// f0r(i,0,n) printf("gar[%lli]: %lli, perm[%lli]: %lli\n", i, (ll)gar[i], i, (ll)perm[i]);
answer(gar, perm);
}
/*
int main()
{
ll N;
printf("n: ");
scanf("%lli", &N);
printf("\n");
exploreCave(N);
return 0;
}
*/
# | 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... |