이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
/**
* Author : boatinw99
* Date : 1.5.2019 14.16
**/
#include "cave.h"
#include<bits/stdc++.h>
using namespace std ;
#define mid (l+r>>1)
const int N = 5009 ;
void mem(int l,int r,int val,int *S,int *D)
{
for(int i=l;i<=r;i++)
{
if(D[i]==-1)S[i]=val;
}
}
void solve(int l,int r,int state,int x,int *S,int *D)
{
if(l==r)
{
//printf("chk l=%d state=%d x=%d\n",l,state,x);
D[l]=x;
S[l]=state;
return ;
}
mem(l,mid,state^1,S,D);
int ret = tryCombination(S);
///printf("chk (%d %d) %d \n",l,r,ret);
if(ret==x)
{
mem(l,mid,state,S,D);
solve(l,mid,state,x,S,D);
}
else solve(mid+1,r,state,x,S,D);
}
void exploreCave(int n)
{
int S[n],D[n];
memset(D,-1,sizeof D);
memset(S,0,sizeof S);
for(int i=0;i<n;i++)
{
mem(0,n-1,0,S,D);
int ret = tryCombination(S);
if(ret<i)while(1);
else if(ret>i)solve(0,n-1,0,i,S,D);
else
{
mem(0,n-1,1,S,D);
solve(0,n-1,1,i,S,D);
}
//break;
}
answer(S,D);
}
컴파일 시 표준 에러 (stderr) 메시지
cave.cpp: In function 'void solve(int, int, int, int, int*, int*)':
cave.cpp:8:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
#define mid (l+r>>1)
~^~
cave.cpp:26:11: note: in expansion of macro 'mid'
mem(l,mid,state^1,S,D);
^~~
cave.cpp:8:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
#define mid (l+r>>1)
~^~
cave.cpp:31:15: note: in expansion of macro 'mid'
mem(l,mid,state,S,D);
^~~
cave.cpp:8:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
#define mid (l+r>>1)
~^~
cave.cpp:32:17: note: in expansion of macro 'mid'
solve(l,mid,state,x,S,D);
^~~
cave.cpp:8:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
#define mid (l+r>>1)
~^~
cave.cpp:34:16: note: in expansion of macro 'mid'
else solve(mid+1,r,state,x,S,D);
^~~
# | 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... |