이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
const int NBIT = 2;
std::pair<int,int> decode(int encoded) {
return {
NBIT - encoded / 3 - 1,
encoded % 3,
};
}
int encode(int bit, int t) {
if (bit < 0) return 0;
return (NBIT - bit - 1) * 3 + t;
}
std::vector<std::vector<int>> devise_strategy(int n) {
const int NSTATE = NBIT * 3;
std::vector<std::vector<int>> res(NSTATE, std::vector<int> (n+1, 0));
for (int state = 0; state < NSTATE; ++state) {
auto [bit, t] = decode(state);
if (t == 0) res[state][0] = 0;
else res[state][0] = 1;
for (int i = 1; i <= n; ++i) {
std::bitset<NBIT> bits {(unsigned) i};
if (t == 0) {
res[state][i] = encode(bit, bits[bit] + 1);
} else {
int a_bit = t - 1;
int b_bit = bits[bit];
if (a_bit < b_bit) res[state][i] = -1;
else if (a_bit > b_bit) res[state][i] = -2;
else res[state][i] = encode(bit - 1, 0);
}
}
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |