Submission #755311

#TimeUsernameProblemLanguageResultExecution timeMemory
755311Red_InsidePrisoner Challenge (IOI22_prison)C++17
100 / 100
14 ms1016 KiB
#include "prison.h" #include <bits/stdc++.h> //#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops") #define ll long long #define f first #define s second #define pb push_back #define mp make_pair #define o cout<<"BUG"<<endl; #define FOR(i, j, n) for(int j = i; j < n; ++j) #define forn(i, j, n) for(int j = i; j <= n; ++j) #define nfor(i, j, n) for(int j = n; j >= i; --j) #define all(v) v.begin(), v.end() #define ld long double #define ull unsigned long long using namespace std; const int maxn=2e5+10,LOG=17,mod=1e9+7; int block = 650, timer = 0; const double eps = 1e-9; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); #define bt(i) (1 << (i)) //#define int ll const long long inf=2e18; #define y1 yy #define pii pair <int, int> int etot(int x) { return (x == 0 ? -1 : -2); } int oppo(int x) { return (x == 0 ? -2 : -1); } pii seg(int x, int n) { int l = 1; int r = 5000; forn(1, i, n) { l++; r--; int m1 = l + (r - l) / 3; int m2 = l + 2*(r - l) / 3; if(x <= m1) { r = m1; } else if(m1 < x && x <= m2) { l = m1+1; r = m2; } else { l = m2+1; } } return {l, r}; } int to(int x, int n) { int l = 1; int r = 5000; int last = 0; forn(1, i, n) { l++; r--; int m1 = l + (r - l) / 3; int m2 = l + 2*(r - l) / 3; if(x <= m1) { last = 0; r = m1; } else if(m1 < x && x <= m2) { last = 1; l = m1+1; r = m2; } else { last = 2; l = m2+1; } } return last; } vector <vector <int> > devise_strategy(int n) { vector <vector <int> > turn(21); forn(0, i, 20) { turn[i].assign(n+1, 0); } turn[0][0] = 0; forn(1, x, n) { if(x == 1) turn[0][x] = -1; else if(x == 5000) turn[0][x] = -2; else turn[0][x] = 1+to(x, 1); } forn(1, i, 18) { int iter = (i - 1) / 3+1; turn[i][0] = (iter % 2 == 1 ? 1 : 0); forn(1, x, n) { pii ret = seg(x, iter); int l = ret.f; int r = ret.s; int was = to(x, iter); // if(i == 1 && x == 189) cout << was << " " << l << " " << r << " " << iter << endl; int poin = (i - 1) % 3; if(was < poin) { turn[i][x] = etot(turn[i][0]); continue; } if(poin < was) { turn[i][x] = oppo(turn[i][0]); continue; } if(x <= l) { turn[i][x] = etot(turn[i][0]); continue; } if(r <= x) { turn[i][x] = oppo(turn[i][0]); continue; } if(iter == 6) { l++; r--; int mid = (l + r) / 2; if(x <= mid) { turn[i][x] = 19; } else { turn[i][x] = 20; } continue; } int kuda = to(x, iter+1); // if(i == 1 && x == 189) // cout << " KUDA " << kuda << endl; turn[i][x] = iter*3+1+kuda; } } turn[19][0] = (turn[18][0]^1); turn[20][0] = turn[19][0]; forn(1, x, n) { pii ret = seg(x, 6); int l = ret.f + 1; int r = ret.s - 1; int mid = (l + r) / 2; if(x <= l) { turn[19][x] = etot(turn[19][0]); } else { turn[19][x] = oppo(turn[19][0]); } if(x <= mid+1) { turn[20][x] = etot(turn[20][0]); } else { turn[20][x] = oppo(turn[20][0]); } } return turn; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...