This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "prison.h"
#include "bits/stdc++.h";
using namespace std;
#define forR(i, x) for(int i = 0; i < (x); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) x.begin(), x.end()
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int> vi;
typedef vector<vi> vvi;
struct pii{int a, b;};
std::vector<std::vector<int>> devise_strategy(int N) {
int mb = 0;
forR(i, 20) if(N & (1 << i)) mb = i;
vvi ret(2 * (mb+1) + 1, vi(N+1));
ret[0][0] = 0;
REP(val, 1, N+1) {
if(val & (1 << mb)) ret[0][val] = 2;
else ret[0][val] = 1;
}
for(int i = mb; i >= 0; --i) {
int ordInd = mb - i;
int b0i = ordInd * 2 + 1, b1i = ordInd * 2 + 2;
ret[b0i][0] = ret[b1i][0] = ordInd % 2 == 0 ? 1 : 0;
REP(val, 1, N+1) {
int cbt = val & (1 << i);
if(cbt > 0) {
ret[b0i][val] = ordInd % 2 == 0 ? -1 : -2;
if(i > 0) {
ret[b1i][val] = (val & (1 << (i-1))) ? ordInd * 2 + 4 : ordInd * 2 + 3;
}
} else {
ret[b1i][val] = ordInd % 2 == 0 ? -2 : -1;
if(i > 0) {
ret[b0i][val] = (val & (1 << i-1)) ? ordInd * 2 + 4 : ordInd * 2 + 3;
}
}
}
}
return ret;
}
Compilation message (stderr)
prison.cpp:2:25: warning: extra tokens at end of #include directive
2 | #include "bits/stdc++.h";
| ^
prison.cpp: In function 'std::vector<std::vector<int> > devise_strategy(int)':
prison.cpp:37:41: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
37 | ret[b0i][val] = (val & (1 << i-1)) ? ordInd * 2 + 4 : ordInd * 2 + 3;
| ~^~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |