# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
634064 | Utaha | Prisoner Challenge (IOI22_prison) | C++17 | 0 ms | 0 KiB |
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;
std::vector<std::vector<int>> devise_strategy(int N) {
// 13 bits in total to check
// check A ith bit: 0~12
// check B ith bit, knowing A's ith bit = 0: 13~25
// check B ith bit, knowing A's ith bit = 1: 26~38
const int m = 13;
const int checkA = 0;
const int checkB0 = m;
const int checkB1 = m + m;
for (int i = 0; i < m; i++) {
vector<int> v;
v.clear();
v.push_back(0); // bag A
for (int j = 0; j < N; j++) {
if (j & (1 << i)) {
v.push_back(checkB1 + i);
}
else {
v.push_back(checkB0 + i);
}
}
}
//checkB0
for (int i = 0; i < m; i++) {
vector<int> v;
v.clear();
v.push_back(1); // bag B
for (int j = 0; j < N; j++) {
if (j & (1 << i)) {
v.push_back(-1); // report B > A
}
else {
v.push_back(checkA + i + 1);
}
}
}
//checkB1
for (int i = 0; i < m; i++) {
vector<int> v;
v.clear();
v.push_back(1); // bag B
for (int j = 0; j < N; j++) {
if (j & (1 << i)) {
v.push_back(checkA + i + 1);
}
else {
v.push_back(-2); // report A > B
}
}
}
return v;
}