Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "cave.h"
- #include <iostream>
- const int maxn = 5050;
- int S[maxn], D[maxn];
- int switched[maxn];
- void exploreCave(int N) {
- for(int i = 0; i < N; i++) {
- int comb = (tryCombination(S) != i);
- int L = 0, R = N - 1;
- while(L < R) {
- int mid = (L + R) / 2;
- for(int j = L; j <= mid; j++) {
- if(!switched[j]) {
- S[j] = 1 - S[j];
- }
- }
- int comb2 = (tryCombination(S) != i);
- for(int j = L; j <= mid; j++) {
- if(!switched[j]) {
- S[j] = 1 - S[j];
- }
- }
- if(comb == comb2) {
- L = mid + 1;
- }
- else {
- R = mid;
- }
- }
- D[L] = i;
- if(comb == 0) {
- S[L] = 1 - S[L];
- }
- switched[L] = 1;
- }
- answer(S, D);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement