이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "cave.h"
#include<stdio.h>
static int sw[5005];
static int de[5005];
void exploreCave(int N) {
int i, j;
int l, r, m;
int s[5005];
for(i=0; i<N;i++)
{
sw[i] = -1;
s[i] = -1;
de[i] = -1;
}
int result1;
int result2;
for(i=0; i<N; i++)
{
l=0;r=N-1;
while(l<r)
{
m=(l+r)/2;
for(j=l;j<=r;j++)
{
if(sw[j]==-1)
s[j]=1;
else
s[j]=sw[j];
}
result1 = tryCombination(s);
for(j=l;j<=m;j++)
{
if(sw[j]==-1)
s[j]=0;
else
s[j]=sw[j];
}
result2 = tryCombination(s);
// for(j=l;j<=r;j++)
// printf("%d",s[j]);
// printf("\n");
// printf("%d %d %d, %d %d\n",l,m,r, result1,result2);
if(result1 != i)
{
if(result2 == i)
{
r=m;
}
else
{
if(m==l)
l=m+1;
else
l=m;
}
}
else
{
if(result2==i)
{
if(m==l)
l=m+1;
else
l=m;
}
else
{
r=m;
}
}
}
// printf("%d\n",l);
s[l] = 0;
result1 = tryCombination(s);
s[l] = 1;
result2 = tryCombination(s);
if(result1 == i) sw[l] = 1;
else sw[l] = 0;
de[l] = i;
}
answer(sw, de);
}
# | 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... |