제출 #578859

#제출 시각아이디문제언어결과실행 시간메모리
578859enerelt14동굴 (IOI13_cave)C++14
100 / 100
648 ms468 KiB
#include "cave.h" #include<bits/stdc++.h> using namespace std; void exploreCave(int N) { int n=N, s[N], d[N], re[N], ans[N]; for (int i=0;i<N;i++){ bool is=0; for (int j=0;j<n;j++)s[j]=0; for (int j=0;j<i;j++)s[re[j]]=ans[re[j]]; if (tryCombination(s)==i)is=1; else is=0; int l=0, r=N-1; while(l!=r){ int mid=(l+r)/2; for (int j=l;j<=mid;j++)s[j]=1-s[j]; for (int j=0;j<i;j++)s[re[j]]=ans[re[j]]; if (tryCombination(s)==i){ if (is)l=mid+1; else{ is=1; r=mid; } } else{ if (is){ is=0; r=mid; } else l=mid+1; } } d[l]=i; re[i]=l; if (is){ ans[l]=1-s[l]; } else{ ans[l]=s[l]; } } answer(ans, d); }
#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...