제출 #1310761

#제출 시각아이디문제언어결과실행 시간메모리
1310761jinjikhadzegiorgi동굴 (IOI13_cave)C++20
컴파일 에러
0 ms0 KiB
#include "cave.h"

void exploreCave(int n) {
    // create s, sFinal, dFinal and found arrays
	int s[n], sFinal[n], dFinal[n];
    bool found[n];
    
    // assign starting value to s and found, 0 to both 
    for(int i=0; i<n; i++){
    	s[i]=0;
    	found[i]=false;
	}
	
	
	// start finding which swich opens door i
	for(int i=0; i<n; i++){
		// reset the ones that we didnt explore
		for(int j=0; j<n; j++){
			if(!found[j])s[j]=0;
		}
		
		// check if ith door will open
		int res=tryCombination(s);
		int targetState;
		if(res==-1 || res>i){
			// if yes, set val to 0
			targetState=0;
		}else{
			// if nah, set val to 1
			targetState=1;
		}
		
		// left, right, and switch for ith door
		int l=0; int r=n-1; int scwch=-1;
		while(l<=r){
			// find middle
			int m=(l+r)/2;
			// set all unexplored switches in left half
			for(int j=i; j<n; j++){
				if(!found[j]){
					if(j>=l && j<=m){
						s[j]=targetState;
					}else{
						s[j]=1-targetState;
					}
				}
			}
			// check in which half our switch is located at
			int res2=tryCombination(s);
			if(res2==-1 || res2>i){
				r=m-1;
				swch=m;
			}else{
				l=m+1;
			}
			
		}
		
		// update found, sFinal, dFinal and s arrays
		found[swch]=true;
		sFinal[swch]=targetState;
		dFinal[swch]=i;
		s[swch]=targetState;
		
		
	}
	// print answer
	answer(sFinal, dFinal);
    
    
}

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:52:33: error: 'swch' was not declared in this scope; did you mean 'scwch'?
   52 |                                 swch=m;
      |                                 ^~~~
      |                                 scwch
cave.cpp:60:23: error: 'swch' was not declared in this scope; did you mean 'scwch'?
   60 |                 found[swch]=true;
      |                       ^~~~
      |                       scwch