Submission #132058

#TimeUsernameProblemLanguageResultExecution timeMemory
132058junodeveloperCave (IOI13_cave)C++14
51 / 100
360 ms640 KiB
#include "cave.h" #include <bits/stdc++.h> #define sz(x) (int)x.size() using namespace std; int S[5010], D[5010], cur, idx, W, n; int Try() { int r = tryCombination(S); return r == -1 ? n : r; } void FindAll(int s, int e) { vector<int> a; for(int i=s; i<=e; i++) if(D[i] == -1) a.push_back(i); int B = (int)sqrt(sz(a)); if(s == 0 && e == n - 1) B = (sz(a) + 9) / 10; else B = (sz(a) + 1) / 2; for(int i=0; i<sz(a); i+=B) { int rgt = min(sz(a), i+B); for(int j=i; j<rgt; j++) S[a[j]] ^= 1; int r = Try(); for(int j=i; j<rgt; j++) S[a[j]] ^= 1; if(r != idx) { if(B == 1) { if(idx < r) { D[a[i]] = idx; W = a[i]; } else if(r < idx) D[a[i]] = r; } else FindAll(a[i], a[rgt - 1]); } } } void exploreCave(int N) { n = N; srand(123); memset(D, -1, sizeof(D)); for(int i=0; i<N; i++) S[i] = rand() % 2; cur = 0; while(cur < N) { idx = Try(); FindAll(0, n - 1); if(idx < n) S[W] ^= 1; cur = idx + 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...