제출 #964138

#제출 시각아이디문제언어결과실행 시간메모리
964138maxFedorchuk동굴 (IOI13_cave)C++17
100 / 100
691 ms768 KiB
#include <bits/stdc++.h> #include <cave.h> using namespace std; const long long MX=5e3+10; int zal[MX],pol[MX]; int n; void cnt(int in) { int zap[n]; for(int i=0;i<n;i++) { zap[i]=(pol[i]==-1?0:pol[i]); } int rt=tryCombination(zap),ndc; if(rt==-1) { rt=n; } if(rt>in) { ndc=0; } else { ndc=1; } int l=0,r=n-1; while(l<r) { int mid=(l+r)/2; for(int i=0;i<n;i++) { zap[i]=pol[i]; if(zap[i]==-1) { if(l<=i && i<=mid) { zap[i]=ndc; } else { zap[i]=(ndc^1); } } } rt=tryCombination(zap); if(rt==-1) { rt=n; } if(rt>in) { r=mid; } else { l=mid+1; } } zal[r]=in; pol[r]=ndc; } void exploreCave(int N) { n=N; for(int i=0;i<n;i++) { pol[i]=-1; zal[i]=-1; } for(int i=0;i<n;i++) { cnt(i); } int anspol[n],anszal[n]; for(int i=0;i<n;i++) { anspol[i]=pol[i]; anszal[i]=zal[i]; } answer(anspol,anszal); }
#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...