Submission #481191

#TimeUsernameProblemLanguageResultExecution timeMemory
481191nadorbCave (IOI13_cave)C++14
100 / 100
971 ms460 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; void exploreCave(int n) { int s[n], known[n], whereto[n]; for(int i = 0; i < n; i++){ known[i] = -1; whereto[i] = -1; } for(int i = 0; i < n; i++){ // minden ajtora for(int j = 0; j < n; j++){ if(known[j] == -1){ s[j] = 1; } else{ s[j] = known[j]; } } int g = tryCombination(s); bool door = (g == -1 || g > i); int l = 0, r = n - 1; while(l < r && i < n - 1){ int mid = (l + r) / 2; for(int j = 0; j < n; j++){ if(known[j] > -1){ s[j] = known[j]; } else{ if(l <= j && j <= mid){ s[j] = door; } else{ s[j] = 1 - door; } } } int res = tryCombination(s); if(res == - 1 || res > i){ r = mid; } else{ l = mid + 1; } } if(i == n - 1){ for(int j = 0; j < n; j++){ if(whereto[j] == -1){ whereto[j] = n - 1; known[j] = door; } } } else{ whereto[l] = i; known[l] = door; } } answer(known, whereto); }
#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...