Submission #492471

#TimeUsernameProblemLanguageResultExecution timeMemory
4924711neCave (IOI13_cave)C++14
Compilation error
0 ms0 KiB
//#include "cave.h"
#include<bits/stdc++.h>
using namespace std;
void exploreCave(int n) {
    /* ... */
    int cur = 0;
    int swit[n] = {-1};
  	int ans[n] = {0};
    while(cur<n){
    	int left = 0,right = n-1;
      while(left<=right){
      	int val = -1;
       for (int j = 0;j<2;++j){
        	vector<int>temp(n,0);
        	int mid = (left + right)>>1;
        	for (int i = 0;i<mid;++i){
        		if (swit[i]==-1){
        		temp[i] = j;
        		}
        		else temp[i] = ans[i];
        	}
			for (int i = mid;i<n;++i){
				if (swit[i]==-1){
					temp[i] = j;
				}
				else{
					temp[i] = ans[i];
				}
			}
			int a = tryCombination(temp);
			if (a>cur){
				val = j;
				break;
			}
       }
       assert(val!=-1);
       vector<int>temp(n,0);
       	int mid = (left + right)>>1;
       	for (int i = 0;i<mid;++i){
       		if (swit[i]==-1){
       			temp[i] = val;
       		}
       		else temp[i] = ans[i];	
       	}
        for (int i = mid;i<n;++i){
        	if (swit[i]==-1){
        		temp[i] = val^1;
        	}
        	else temp[i] = ans[i];
        }
        int a = tryCombination(temp);
        if (a>cur){
        	right = mid-1;
        }
        else{
            left = mid;
        }
      }
      swit[left] = cur;
      ans[left] = val;
      ++cur;
    }
    answer(ans,swit);
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:30:12: error: 'tryCombination' was not declared in this scope
   30 |    int a = tryCombination(temp);
      |            ^~~~~~~~~~~~~~
cave.cpp:51:17: error: 'tryCombination' was not declared in this scope
   51 |         int a = tryCombination(temp);
      |                 ^~~~~~~~~~~~~~
cave.cpp:60:19: error: 'val' was not declared in this scope
   60 |       ans[left] = val;
      |                   ^~~
cave.cpp:63:5: error: 'answer' was not declared in this scope
   63 |     answer(ans,swit);
      |     ^~~~~~