Submission #291200

#TimeUsernameProblemLanguageResultExecution timeMemory
291200Ruba_KCave (IOI13_cave)C++14
100 / 100
1088 ms764 KiB
#include "cave.h" #include<bits/stdc++.h> using namespace std ; void exploreCave(int N) { int constant[N] , arr[N] , pos[N]; memset(constant , 0 , sizeof constant); for(int i = 0 ; i < N ; i ++) arr[i] = i % 2 ; for(int i = 0 ; i < N ; i ++){ int ret = tryCombination(arr); if(ret != i){ for(int j = 0 ; j < N ; j ++){ if(constant[j])continue ; arr[j] = (arr[j] + 1 ) % 2 ; } } int l = 0 , r = N - 1 , md ; while(l < r){ md = (l + r) / 2 ; int check[N]; for(int j = 0 ; j < N ; j ++){ if(constant[j]){ check[j] = arr[j]; continue ; } check[j] = (j >= l && j <= md ? arr[j] : arr[j] ^ 1); } ret = tryCombination(check); if(ret == i)r = md ; else l = md + 1 ; } constant[l] = 1 ; arr[l] ^= 1 ; pos[l] = i ; } answer(arr , pos); }
#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...