Submission #941978

#TimeUsernameProblemLanguageResultExecution timeMemory
9419784QT0RCave (IOI13_cave)C++17
100 / 100
534 ms604 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; void exploreCave(int n){ int cor[n]; fill(cor,cor+n,-1); int pos[n]; fill(pos,pos+n,-1); int S[n]; int kolor,odp,l,p,md,cur=0; for (int i = 0; i<n; i++){ for (int j = 0; j<n; j++){ if (cor[j]>=0)S[j]=cor[j]; else S[j]=0; } odp=tryCombination(S); if (odp==-1 || odp>i)kolor=0; else kolor=1; l=1,p=n-i; while(l<p){ md=(l+p)/2; cur=0; for (int j = 0; j<n; j++){ if (cor[j]>=0)S[j]=cor[j]; else if (cur++<md)S[j]=kolor; else S[j]=kolor^1; } odp=tryCombination(S); if (odp==-1 || odp>i)p=md; else l=md+1; } cur=0; for (int j = 0; j<n; j++){ if (cor[j]<0 && ++cur==l)odp=j; } cor[odp]=kolor; pos[odp]=i; } answer(cor,pos); }
#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...