# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1082615 | vjudge1 | Radio Towers (IOI22_towers) | 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>
#define ent '\n'
using namespace std;
vector<vector<int>> a;
void get(int l, int r, int i, int c){
if(l >= r){
return;
}
a[i][0] = c;
a[i][l] = -(c + 1);
a[i][r] = -((c ^ 1) + 1);
if(i > 0) l++, r--;
if(l >= r) return;
if(0 < i && i <= 12){
int cur = (i - 1) % 3;
int m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
for(int x=l;x<=r;x++){
int val = 0;
if(x > m1) val++;
if(x > m2) val++;
if(val != cur){
if(val < cur) a[i][x] = -(c + 1);
else a[i][x] = -((c ^ 1) + 1);
}
}
if(cur == 0) r = m1;
if(cur == 1) l = m1 + 1, r = m2;
if(cur == 2) l = m2 + 1;
}
else if(i > 0){
int cur = (i - 13) % 2;
int mid = l + r >> 1;
for(int x=l;x<=r;x++){
int val = (x > mid);
if(val != cur){
if(val < cur) a[i][x] = -(c + 1);
else a[i][x] = -((c ^ 1) + 1);
}
}
if(!cur) r = mid;
else l = mid + 1;
}
a[i][l] = -(c + 1);
a[i][r] = -((c ^ 1) + 1);
l++, r--;
if(l > r) return;
if(i < 10){
int b = ((i + 2) / 3) * 3 + 1;
int m1 = l + (r - l) / 3, m2 = r - (r - l) / 3;
for(int x=l;x<=r;x++){
if(x <= m1) a[i][x] = b;
else if(x <= m2) a[i][x] = b + 1;
else a[i][x] = b + 2;
}
get(l-1, r+1, b, 1 - c);
get(l-1, r+1, b + 1, 1 - c);
get(l-1, r+1, b + 2, 1 - c);
}
else{
int b = i + (i % 2) + 1;
if(i == 10) b = 13;
int mid = l + r >> 1;
for(int x=l;x<=r;x++){
if(x <= mid) a[i][x] = b;
else a[i][x] = b + 1;
}
get(l-1, r+1, b, 1 - c);
get(l-1, r+1, b + 1, 1 - c);
}
}
vector<vector<int>> devise_strategy(int n) {
int k = 20;
for(int i=0;i<=k;i++){
a.push_back(vector<int> (6600, 0));
}
get(1, 5000, 0, 0);
for(int i=0;i<=k;i++){
while(a[i].size() > n + 1){
a[i].pop_back();
}
}
return a;
}