# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078795 | LittleOrange | Prisoner Challenge (IOI22_prison) | C++17 | 20 ms | 1368 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 <vector>
#include<bits/stdc++.h>
using namespace std;
using ll = int;
const ll m = 4;
ll g(ll x, ll lv){
//cerr << "g " << x << " " << lv;
while(lv-->0) x/=m;
//cerr << " = " << x%m << "\n";
return x%m;
}
ll cal(ll x){
ll r = -1;
while(x){
r++;
x/=m;
}
return r;
}
std::vector<std::vector<int>> devise_strategy(int N) {
ll n = N;
ll lvl = cal(n);
vector<vector<ll>> ret;
vector<ll> mp;
{
vector<ll> a(n+1,0);
for(ll i = 1;i<=n;i++) a[i] = g(i,lvl)+1;
ret.push_back(a);
}
for(ll j = 0;j<=lvl;j++){
ll h = lvl-j;
ll tp = j&1^1;
for(ll x = 0;x<m;x++){
vector<ll> a(n+1,tp);
for(ll i = 1;i<=n;i++){
ll v = g(i,h);
if (v<x) a[i] = -1-tp;
else if (v>x) a[i] = -2+tp;
else a[i] = g(i,h-1)+(j+1)*m+1;
}
ret.push_back(a);
}
}
//ofstream stra("str.txt");
//stra << ret.size() << "\n";
ll x = ret.size()-1;
for(auto &o : ret){
for(ll &i : o){
if (i<-2||i>x) i = x;
}
//for(ll i = 0;i<=n;i++) stra << o[i] << " \n"[i==n];
}
return ret;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |