Submission #626207

# Submission time Handle Problem Language Result Execution time Memory
626207 2022-08-11T09:50:15 Z errorgorn Prisoner Challenge (IOI22_prison) C++17
100 / 100
11 ms 1420 KB
#include "prison.h"
 
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
#define ii pair<int,int>
#define fi first
#define se second
 
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
 
#define rep(x,s,e) for (int x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e))?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
 
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

const int MAGIC[]={0,2,3,3,3,3,3,3}; //stupid problem
int pref[9];
int offset[9];

int n;

vector<vector<signed> > v;
void solve(int l,int r,int pl,int pr,int layer,int res){
	rep(x,pl,l+1) if (x<=n) v[offset[layer]+res][x]=-1;
	rep(x,r,pr+1) if (x<=n) v[offset[layer]+res][x]=-2;
	
	if (layer){
		int len=(r-l-1)/MAGIC[layer];
		
		rep(x,0,MAGIC[layer]){
			int l2=l+1+x*len,r2=l2+len-1;
			rep(y,l2,r2+1) if (y<=n) v[offset[layer]+res][y]=offset[layer-1]+x;
			solve(l2,r2,l,r,layer-1,x);
		}
	}
}
 
vector<vector<signed> > devise_strategy(signed N){
	n=N;
	v=vector<vector<signed> >(21,vector<signed>(n+1,0));
	
	pref[0]=0;
	rep(x,0,8) pref[x+1]=pref[x]*MAGIC[x]+2;
	
	offset[7]=0;
	offset[6]=1;
	rep(x,6,0) offset[x]=offset[x+1]+MAGIC[x+2];
	
	solve(1,pref[8],1,pref[8],7,0);
	
	for (int x=0;x<7;x+=2) rep(y,offset[x+1],offset[x]) v[y][0]=1;
	
	rep(x,0,21) if (v[x][0]) for (auto &it:v[x]) if (it<=-1) it^=1;
	
	return v;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 340 KB Output is correct
6 Correct 2 ms 396 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 396 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 2 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 5 ms 724 KB Output is correct
5 Correct 9 ms 1108 KB Output is correct
6 Correct 11 ms 1420 KB Output is correct
7 Correct 11 ms 1364 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Correct 5 ms 724 KB Output is correct
12 Correct 8 ms 1108 KB Output is correct