Submission #650245

#TimeUsernameProblemLanguageResultExecution timeMemory
650245NintsiChkhaidzeCave (IOI13_cave)C++14
100 / 100
1032 ms596 KiB
#include "cave.h" #include <iostream> #define pb push_back using namespace std; const int N = 5005; int s[N],d[N],mx[N],s1[N],s2[N],n; bool f[N]; int opp(int l,int r){ for (int i = 0; i < n; i++){ s1[i] = s[i]; if (f[i]) continue; if (l <= i && i <= r) s1[i] = 1 - s1[i]; } return tryCombination(s1); } void exploreCave(int N) { n=N; for (int i = 0; i < N; i++){ for (int j = 0; j < N; j++){ s1[j] = s2[j] = s[j]; if (f[j]) continue; s1[j] = 0; s2[j] = 1; } bool q = 0; if (tryCombination(s1) == i) { for (int j =0;j<N;j++) s[j] = s1[j]; } else { q=1; for (int j =0;j<N;j++) s[j] = s2[j]; } int l = 0,r = N - 1,res=-1; while (l <= r){ int mid = (l + r)/2; if (opp(l,mid) != i) res = mid, r = mid-1; else l = mid + 1; } f[res] = 1; d[res] = i; if (q) s[res] = 0; else s[res] = 1; } answer(s,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...