Submission #216211

#TimeUsernameProblemLanguageResultExecution timeMemory
216211MODDICave (IOI13_cave)C++14
Compilation error
0 ms0 KiB
#include "cave.h"
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vll vector<pll>
#define vii vector<pii>
using namespace std;
 
void exploreCave(int n){
	int door[n], guess[n], status[n];
	memset(door,-1,sizeof(door));
	for(int i = 0; i < n; i++){
		int before_swap = tryCombination(status);
		int l = 0, r = n - 1;
		while(l <= r){
			bool ok = false;
			int mid = (r + l) / 2;
			for(int i = 0; i < n; i++){
				if(i >= l && i <= mid){
					if(door[i] != -1)
						guess[i] = status[i];
					else{
						guess[i] = !status[i];
						changed = true;
					}
				}
				else
					guess[i] = status[i];
			}
			int K = before_swap;
			if(changed)
				K = tryCombination(guess);
				
			if(before_swap == i){
				if(K > i || K == -1)
					h = mid;
				else
					l = mid + 1;
			}
			else{
				if(K == i)
					h = mid;
				else
					l = mid + 1;
			}
		}
		door[l] = i;
		if(before_swap == i)
			status[l] = !status[l];
	}
	answer(status,door);
}

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:27:7: error: 'changed' was not declared in this scope
       changed = true;
       ^~~~~~~
cave.cpp:34:7: error: 'changed' was not declared in this scope
    if(changed)
       ^~~~~~~
cave.cpp:39:6: error: 'h' was not declared in this scope
      h = mid;
      ^
cave.cpp:45:6: error: 'h' was not declared in this scope
      h = mid;
      ^
cave.cpp:19:9: warning: unused variable 'ok' [-Wunused-variable]
    bool ok = false;
         ^~