제출 #1064326

#제출 시각아이디문제언어결과실행 시간메모리
1064326hotboy2703죄수들의 도전 (IOI22_prison)C++17
0 / 100
8 ms604 KiB
#include "prison.h" #include <bits/stdc++.h> using namespace std; using ll = int; #define MP make_pair #define fi first #define se second #define pll pair <ll,ll> #define sz(a) (ll((a).size())) #define BIT(mask,i) (((mask) >> (i))&1LL) #define MASK(i) (1LL<<(i)) std::vector<std::vector<int>> devise_strategy(int n) { vector <vector<ll> > res(23,vector <ll> (n+1,0)); res[0][0] = 0; res[0][1] = -1; res[0][n] = -2; for (ll j = 2;j <= n-1;j ++)res[0][j] = (j > (n+1)/2)+1; for (ll i = 1;i <= 22;i ++){ res[i][0] = !(((i-1)/2)&1); for (ll j = 1;j <= n;j ++){ ll l = 1,r = n; for (ll k = 0;k <= i/2;k ++){ if (r-l <= 1){ r = l-1; break; } if (k==i/2){ l++,r--; ll mid=(l+r)>>1; if (i&1){ r = mid; } else{ l = mid + 1; } } else{ if ((k&1)==res[i][0]){ if (j >= r || j <= l){ r = l - 1; break; } } l++,r--; ll mid=(l+r)>>1; if (mid >= j)r = mid; else l = mid + 1; } } // if (i==2&&j==1)cout<<l<<' '<<r<<'\n'; if (r < l)res[i][j] = -1; else{ if (j >= r)res[i][j] = -(1+(!res[i][0])); else if (j <= l)res[i][j] = -(1+(res[i][0])); else res[i][j] = ((i-1)/2+1)*2+1+(j>(l+r)/2); } } } // cout<<res[0][123]<<' '<<res[2][1]<<'\n'; // for (ll i = 0;i <= 22;i ++){ // for (ll j = 0;j <= n;j ++){ // cout<<res[i][j]<<' '; // } // cout<<'\n'; // } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...