이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
void debug_out(){cerr << endl;}
template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
cerr << H << ' ';
debug_out(T...);
}
#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)
const int maxn = 24;
const int lg = 13;
std::vector<std::vector<int>> devise_strategy(int N) {
// debug(N);
vector<vector<int>> ans;
ans.resize(maxn);
for (int i = 0; i < maxn; i++){
ans[i].resize(N+1);
int bit, val, bag;
if (i == 0){
bit = 13;
val = 0;
bag = 1;
}
else if (i == 1){
bit = (i+1)/2;
val = (i&1);
bag = (((i+1)/2)&1);
}
else{
bit = (i+2)/2;
val = ((i+1)&1);
bag = (((i+2)/2)&1);
}
//debug(i, bit, val, bag);
ans[i][0] = bag;
//debug(i, 0, ans[i][0]);
for (int j = 1; j <= N; j++){
int tmp = ((j >> bit) & 1);
int rem = (1 << bit) - 1;
if (tmp < val){
ans[i][j] = -1 - bag;
}
else if (tmp > val){
ans[i][j] = -1 - (1-bag);
}
else if ((j & rem) == rem){
ans[i][j] = -1 - (1-bag);
}
else if ((j & rem) == 0){
ans[i][j] = -1 - bag;
}
else{
ans[i][j] = (bit-1) * 2 - ((j >> (bit-1)) & 1);
if (ans[i][j] == 1) continue;
if (ans[i][j] == 2) ans[i][j] = -1 - bag;
else ans[i][j]--;
}
// debug(i, j, ans[i][j]);
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |