Submission #1070694

#TimeUsernameProblemLanguageResultExecution timeMemory
1070694c2zi6Prisoner Challenge (IOI22_prison)C++17
38 / 100
26 ms2396 KiB
#define _USE_MATH_DEFINES #include <bits/stdc++.h> #define ff first #define ss second #define pb push_back #define all(a) (a).begin(), (a).end() #define replr(i, a, b) for (int i = int(a); i <= int(b); ++i) #define reprl(i, a, b) for (int i = int(a); i >= int(b); --i) #define rep(i, n) for (int i = 0; i < int(n); ++i) #define mkp(a, b) make_pair(a, b) using namespace std; typedef long long ll; typedef long double ld; typedef pair<int, int> PII; typedef vector<int> VI; typedef vector<PII> VPI; typedef vector<VI> VVI; typedef vector<VVI> VVVI; typedef vector<VPI> VVPI; typedef pair<ll, ll> PLL; typedef vector<ll> VL; typedef vector<PLL> VPL; typedef vector<VL> VVL; typedef vector<VVL> VVVL; typedef vector<VPL> VVPL; template<class T> T setmax(T& a, T b) {if (a < b) return a = b; return a;} template<class T> T setmin(T& a, T b) {if (a < b) return a; return a = b;} #include <ext/pb_ds/assoc_container.hpp> using namespace __gnu_pbds; template<class T> using indset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #include "prison.h" struct QUERY { int type; int ind; int val; /* * type = 0 * grel a-i arjeq@ * type = 1 * hamematel b-i arjeq@ a-i het */ }; bool operator<(const QUERY& a, const QUERY& b) { return make_tuple(a.type, a.ind, a.val) < make_tuple(b.type, b.ind, b.val); } int b = 0; map<int, QUERY> decode; map<QUERY, int> encode; void add(QUERY x) { if (encode.count(x)) return; decode[b] = x; encode[x] = b; b++; } const int himq = 2; const int start = 12; int get(int x, int i) { while (i--) x /= himq; return x % himq; } VVI ans; void prisoner(int id, int x) { auto[type, ind, VAL] = decode[id]; ans[id][0] = type; if (type) { int valA = VAL; int valB = get(x, ind); if (valA < valB) { ans[id][x] = -1; } else if (valA > valB) { ans[id][x] = -2; } else { ind--; if (ind < 0) return; ans[id][x] = encode[{0, ind, 0}]; } } else { int val = get(x, ind); ans[id][x] = encode[{1, ind, val}]; } } VVI devise_strategy(int n) { add({0, start, 0}); replr(ind, 0, start) { add({0, ind, 0}); add({1, ind, 0}); add({1, ind, 1}); } ans = VVI(b, VI(n+1)); rep(i, b) rep(j, n+1) prisoner(i, j); return ans; int A, B; cin >> A >> B; int cur = 0; rep(i, 20) { cout << "ID: " << cur << endl; auto[type, ind, val] = decode[cur]; cout << "grac e " << type << " " << ind << " " << val << endl; int harc = (ans[cur][0] ? B : A); cout << "Harcrec qash@, stacav " << harc << endl; if (ans[cur][harc] == -1) { cout << "PATASXAN@ A" << endl; break; } if (ans[cur][harc] == -2) { cout << "PATASXAN@ B" << endl; break; } cur = ans[cur][harc]; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...