제출 #878976

#제출 시각아이디문제언어결과실행 시간메모리
878976mahmoudbadawy동굴 (IOI13_cave)C++17
100 / 100
165 ms604 KiB
#include "cave.h" const int MX=5005; int known[MX], state[MX], doors[MX]; int prev,n; void ask() { prev=tryCombination(state); } int find_key(int st,int en,int door) { if(st==en) return st; int mid=(st+en)/2; int curp=prev; for(int i=st;i<=mid;i++) { if(!known[i]) state[i]^=1; } ask(); if((curp==door)^(prev==door)) // Key in [st,mid] return find_key(st,mid,door); return find_key(mid+1,en,door); } void exploreCave(int N) { ask(); n=N; for(int i=0;i<n;i++) { int key=find_key(0,n-1,i); if(prev==i) { state[key]^=1; ask(); } known[key]=1; doors[key]=i; } answer(state,doors); }
#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...