Submission #380665

#TimeUsernameProblemLanguageResultExecution timeMemory
380665vishesh312Cave (IOI13_cave)C++17
100 / 100
1044 ms576 KiB
#include "cave.h" #include "bits/stdc++.h" using namespace std; /* #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>; */ #define all(x) begin(x), end(x) #define sz(x) (int)x.size() using ll = long long; const int mod = 1e9+7; void exploreCave(int n) { int s[n], d[n]; vector<bool> avl(n, true); for (int i = 0; i < n; ++i) { s[i] = 0; d[i] = -1; } for (int i = 0; i < n; ++i) { int x = tryCombination(s); bool zero = (x > i or x == -1); int str = 0, pichen = n-1; int tdif = pichen - str; int en = str + tdif / 2; while (str <= en) { int temp[n]; for (int j = 0; j < n; ++j) temp[j] = (avl[j]?zero:s[j]); for (int j = str; j <= en; ++j) { if (avl[j]) { temp[j] = !zero; } } x = tryCombination(temp); if (x > i or x == -1) { if (str == en) { d[str] = i; s[str] = !zero; avl[str] = false; break; } else { int dif = en - str; pichen = en; en = str + dif / 2; } } else { str = en + 1; en = pichen; int dif = en - str; en = str + dif / 2; } } } 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...