Submission #283488

#TimeUsernameProblemLanguageResultExecution timeMemory
283488ShushCave (IOI13_cave)C++17
33 / 100
140 ms512 KiB
#include <bits/stdc++.h>
#include "cave.h"

using namespace std;

int n, *s, *t;

void exploreCave(int N) {
	n = N;
	s = new int[n];
	t = new int[n];
	//Initializing
	for(int i = 0; i < n; i++){
		t[i] = -1;
		s[i] = 0;
	}
	//Subtask 1
//	for(int i = 0; i < n; i++){
//		int c = tryCombination(s);
//		if(c == -1) break;
//		s[c] = 1 - s[c];
//	}
	int j = 0;
	while(j < n){
		int normal_state = tryCombination(s);
		for(int i = 0; i < n; i++){
			if(t[i] != -1) continue;
			s[i] = 1 - s[i]; //Alternation
			int attempt = tryCombination(s);
			if(attempt != normal_state){
				if(attempt == j){
					s[i] = 1 - s[i];
					t[i] = j;
					j++;
					break;
				}
				if(normal_state == j){
					t[i] = j;
					j++;
					break;
				}
			}
			s[i] = 1 - s[i];
		}
	}
	answer(s, t);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...