제출 #213414

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

void exploreCave(int N) {
	vi lef;
	vi q;
	vi D; //door # for switch i 
	for(int i = 0; i < N; i++){
		lef.pb(i);
		q.pb(0);
		D.pb(0);
	}

    for(int i = 0; i < N; i++){
    	//assume q is correct until door i
    	for(auto u: lef){
    		q[u] = 0;
    	}
    	int cor;
    	if(tryCombination(q) == i){
    		//correct for door i is 0
    		cor = 0;
    	}
    	else{
    		//correct for door i is 1
    		cor = 1;
    	}
    	int l = 0;
    	int r = sz(lef)-1;
    	while(l < r){
    		int mid = (l+r)/2;
    		//make l-mid cor, mid+1-r 1-cor.
    		for(int i = 0; i < sz(lef); i++){
    			if(l <= i && i <= mid){
    				q[lef[i]] = cor;
    			}
    			else{
    				q[lef[i]] = 1-cor;
    			}
    		}
    		if(tryCombination(q) == i){
    			l = mid+1;
    		}
    		else r = mid;
    	}

    	//update lef, q, D
    	q[lef[l]] = cor;
    	D[lef[l]] = i;
    	lef.erase(lef.begin()+l);
    }
    answer(q, D);
}

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

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:4:2: error: 'vi' was not declared in this scope
  vi lef;
  ^~
cave.cpp:5:5: error: expected ';' before 'q'
  vi q;
     ^
cave.cpp:6:5: error: expected ';' before 'D'
  vi D; //door # for switch i 
     ^
cave.cpp:8:3: error: 'lef' was not declared in this scope
   lef.pb(i);
   ^~~
cave.cpp:9:3: error: 'q' was not declared in this scope
   q.pb(0);
   ^
cave.cpp:10:3: error: 'D' was not declared in this scope
   D.pb(0);
   ^
cave.cpp:15:18: error: 'lef' was not declared in this scope
      for(auto u: lef){
                  ^~~
cave.cpp:16:7: error: 'q' was not declared in this scope
       q[u] = 0;
       ^
cave.cpp:19:24: error: 'q' was not declared in this scope
      if(tryCombination(q) == i){
                        ^
cave.cpp:28:17: error: 'lef' was not declared in this scope
      int r = sz(lef)-1;
                 ^~~
cave.cpp:28:14: error: 'sz' was not declared in this scope
      int r = sz(lef)-1;
              ^~
cave.cpp:34:9: error: 'q' was not declared in this scope
         q[lef[i]] = cor;
         ^
cave.cpp:37:9: error: 'q' was not declared in this scope
         q[lef[i]] = 1-cor;
         ^
cave.cpp:40:25: error: 'q' was not declared in this scope
       if(tryCombination(q) == i){
                         ^
cave.cpp:47:6: error: 'q' was not declared in this scope
      q[lef[l]] = cor;
      ^
cave.cpp:48:6: error: 'D' was not declared in this scope
      D[lef[l]] = i;
      ^
cave.cpp:51:12: error: 'q' was not declared in this scope
     answer(q, D);
            ^
cave.cpp:51:15: error: 'D' was not declared in this scope
     answer(q, D);
               ^