제출 #133904

#제출 시각아이디문제언어결과실행 시간메모리
133904KieranHorgan동굴 (IOI13_cave)C++17
100 / 100
1151 ms640 KiB
#include "cave.h" #include <bits/stdc++.h> using namespace std; void exploreCave(int N) { int switchOfDoorXIsKnown[N]; int doorOfSwitchXIsKnown[N]; int posOfSwitch[N]; memset(switchOfDoorXIsKnown, -1, sizeof(switchOfDoorXIsKnown)); memset(doorOfSwitchXIsKnown, -1, sizeof(doorOfSwitchXIsKnown)); memset(posOfSwitch, -1, sizeof(posOfSwitch)); int toGuess[N]; for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) if(doorOfSwitchXIsKnown[j] == -1) toGuess[j] = 0; else toGuess[j] = posOfSwitch[j]; bool offIsDown = tryCombination(toGuess) == i; int lo = 0; int hi = N-1; while(lo != hi) { int mid = (lo+hi)/2; for(int j = 0; j < N; j++) if(doorOfSwitchXIsKnown[j] == -1) { if(j <= mid) toGuess[j] = 0; else toGuess[j] = 1; } else { toGuess[j] = posOfSwitch[j]; } if(offIsDown == (tryCombination(toGuess) == i)) hi = mid; else lo = mid+1; } switchOfDoorXIsKnown[i] = lo; doorOfSwitchXIsKnown[lo] = i; posOfSwitch[lo] = offIsDown; } answer(posOfSwitch, doorOfSwitchXIsKnown); }
#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...