Submission #755263

#TimeUsernameProblemLanguageResultExecution timeMemory
755263Red_InsidePrisoner Challenge (IOI22_prison)C++17
80 / 100
13 ms1056 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); } int Bit(int x, int btn) { forn(1, i, btn) x /= 3; return x % 3; } vector <vector <int> > devise_strategy(int n) { vector <vector <int> > turn(23); forn(0, i, 22) { turn[i].assign(n+1, 0); } turn[0][0] = 0; forn(1, x, n) { turn[0][x] = Bit(x, 7)+1; } forn(1, i, 21) { turn[i][0] = ((i - 1) / 3 % 2 == 0 ? 1 : 0); int btn = 7 - (i-1)/3; int prevbit = (i - 1) % 3; forn(1, x, n) { int bit = Bit(x, btn); if(bit > prevbit) turn[i][x] = oppo(turn[i][0]); else if(bit < prevbit) turn[i][x] = etot(turn[i][0]); else { int nxtbit = Bit(x, btn-1); if(btn == 1) { if(nxtbit == 0) turn[i][x] = etot(turn[i][0]); else if(nxtbit == 2) turn[i][x] = oppo(turn[i][0]); else turn[i][x] = 22; } else turn[i][x] = ((i-1)/3+1)*3+1+nxtbit; } } } turn[22][0] = ((22 - 1) / 3 % 2 == 0 ? 1 : 0); forn(1, x, n) { if(x % 3 == 0) turn[22][x] = etot(turn[22][0]); else turn[22][x] = oppo(turn[22][0]); } /*for(auto i : turn) { for(auto j : i) cout << j << " "; cout << endl; }*/ return turn; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...