제출 #285447

#제출 시각아이디문제언어결과실행 시간메모리
285447Bill_00동굴 (IOI13_cave)C++14
컴파일 에러
0 ms0 KiB
#include "cave.h"
int p[10000]={0},a[10000],up[10000];
void dfs(int l,int r,int L,int R,int id,int now){
	for(int i=L;i<=R;i++){
		if(p[i]!=0) continue;
		a[i]+=1;
		a[i]%=2;
	}
	int k=tryCombination(a);
	if(L==R && k!=id && now==0){
		p[L+1]=id;
		up[L+1]=a[L+1];
		return;
	}
	if(L==R && k==id && now==0){
		p[L]=id;
		up[L]=(a[L]+1)%2;
		return;
	}
	if(L==R && k!=id && now==1){
		p[L]=id;
		up[L]=a[L];
		return;
	}
	if(L==R && k==id && now==1){
		p[L+1]=id;
		up[L+1]=(a[L+1]+1)%2;
		return;
	}
	if(k!=id && now==1){
		dfs(L,R,L,(L+R)/2,id,0);
	}
	if(k!=id && now==0){
		if(R+1==l){
			p[l]=id;
			up[l]=a[l];
			return;
		}
		dfs(R+1,l,R+1,(l+R+1)/2,id,0);
	}
	if(k==id && now==1){
		if(R+1==l){
			p[l]=id;
			up[l]=(a[l]+1)%2;
			return;
		}
		dfs(R+1,l,R+1,(l+R+1)/2,id,1);
	}
	if(k==id && now==0){
		dfs(L,R,L,(L+R)/2,id,1);
	}
}
void exploreCave(int n) {
    for(int i=0;i<n;i++){
    	a[i]=1;
	}
	for(int i=1;i<=n;i++){
		int k=tryCombination(a);
		if(k==id) dfs(0,n-1,0,(n-1)/2,i,1);
		else dfs(0,n-1,0,(n-1)/2,i,0)
	}
	answer(up,p);
}

컴파일 시 표준 에러 (stderr) 메시지

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:59:9: error: 'id' was not declared in this scope; did you mean 'i'?
   59 |   if(k==id) dfs(0,n-1,0,(n-1)/2,i,1);
      |         ^~
      |         i
cave.cpp:60:32: error: expected ';' before '}' token
   60 |   else dfs(0,n-1,0,(n-1)/2,i,0)
      |                                ^
      |                                ;
   61 |  }
      |  ~