Submission #492469

#TimeUsernameProblemLanguageResultExecution timeMemory
4924691neCave (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;
    vector<int>swit(n,-1);
    vector<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:7:21: error: 'n' was not declared in this scope
    7 |     vector<int>swit(n,-1);
      |                     ^
cave.cpp:30:12: error: 'trycombination' was not declared in this scope; did you mean 'tryCombination'?
   30 |    int a = trycombination(temp);
      |            ^~~~~~~~~~~~~~
      |            tryCombination
cave.cpp:51:17: error: 'trycombination' was not declared in this scope; did you mean 'tryCombination'?
   51 |         int a = trycombination(temp);
      |                 ^~~~~~~~~~~~~~
      |                 tryCombination
cave.cpp:60:19: error: 'val' was not declared in this scope
   60 |       ans[left] = val;
      |                   ^~~
cave.cpp:63:12: error: cannot convert 'std::vector<int>' to 'int*'
   63 |     answer(ans,swit);
      |            ^~~
      |            |
      |            std::vector<int>
In file included from cave.cpp:1:
cave.h:9:17: note:   initializing argument 1 of 'void answer(int*, int*)'
    9 | void answer(int S[], int D[]);
      |             ~~~~^~~