Submission #199527

#TimeUsernameProblemLanguageResultExecution timeMemory
199527johuthaCave (IOI13_cave)C++14
100 / 100
1229 ms640 KiB
#include "cave.h" #include <iostream> #include <vector> #include <set> using namespace std; void exploreCave(int n) { vector<int> defined(n, -1); vector<int> perm(n, -1); int mv = tryCombination(vector<int>(n, 0).data()); for (int i = 0; i < n; i++) { int left = n - i; int ft = 0; for (; left > 1;) { int op = left / 2; vector<int> q = defined; int nds = 0; for (int i = 0; i < n; i++) { if (q[i] == -1 && op > 0 && nds >= ft) { nds++; op--; q[i] = 1; } else if (q[i] == -1) { q[i] = 0; nds++; } } int res = tryCombination(q.data()); if ((res == i) == (mv == i)) { ft += left / 2; left = left - (left / 2); } else left /= 2; } for (int j = 0; j < n; j++) { if (defined[j] == -1 && ft == 0) { defined[j] = (mv == i); perm[j] = i; // cout << "Found " << i << ": Switch " << j << " on " << (mv == i) << "\n"; break; } if (defined[j] == -1) ft--; } vector<int> ov = defined; for (int i = 0; i < n; i++) if (ov[i] == -1) ov[i] = 0; mv = tryCombination(ov.data()); } answer(defined.data(), perm.data()); }
#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...