Submission #599617

#TimeUsernameProblemLanguageResultExecution timeMemory
599617thezomb1eCave (IOI13_cave)C++17
100 / 100
669 ms496 KiB
#include "cave.h" #include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> #define eb emplace_back #define pb push_back #define ft first #define sd second #define pi pair<int, int> #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define dbg(...) dbg_out(__VA_ARGS__) using ll = long long; using ld = long double; using namespace std; using namespace __gnu_pbds; //Constants const ll INF = 5 * 1e18; const int IINF = 2 * 1e9; const ll MOD = 1e9 + 7; // const ll MOD = 998244353; const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}; const ld PI = 3.14159265359; //Templates template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) {return os << '(' << p.first << ", " << p.second << ')';} template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) {os << '['; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << ']';} void dbg_out() {cerr << endl;} template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << H << ' '; dbg_out(T...); } template<typename T> void mins(T& x, T y) {x = min(x, y);} template<typename T> void maxs(T& x, T y) {x = max(x, y);} template<typename T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; template<typename T> using omset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>; // void exploreCave(int n) { int S[n], D[n]; vector<int> right_pos(n, -1); for (int _i = 0; _i < n; _i++) { // find the switch that opens the _i's door for (int i = 0; i < n; i++) { if (right_pos[i] == -1) { S[i] = 1; } else { S[i] = right_pos[i]; } } int pos = tryCombination(S); bool on = (pos == -1 || pos > _i); int lo = 0, hi = n - 1, res; while (lo <= hi) { int mi = (lo + hi) / 2; for (int i = 0; i < n; i++) { if (right_pos[i] == -1) { if (i <= mi) S[i] = on; else S[i] = !on; } else { S[i] = right_pos[i]; } } pos = tryCombination(S); if (pos == -1 || pos > _i) { res = mi; hi = mi - 1; } else { lo = mi + 1; } } D[res] = _i; right_pos[res] = on; } for (int i = 0; i < n; i++) S[i] = right_pos[i]; answer(S, D); }

Compilation message (stderr)

cave.cpp: In function 'void exploreCave(int)':
cave.cpp:76:22: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
   76 |         right_pos[res] = on;
      |                      ^
#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...