Submission #739792

#TimeUsernameProblemLanguageResultExecution timeMemory
739792NonozePrisoner Challenge (IOI22_prison)C++17
10 / 100
14 ms1044 KiB
#include "prison.h"

#include <bits/stdc++.h>
using namespace std;

vector<vector<int>> devise_strategy(int n) {
	vector<vector<int>> ans(27, vector<int> (n+1, 0));
	for (int i = 1; i <= n; ++i)
	{
		ans[0][i]=26;
	}
	for (int i = 1; i < 27; ++i)
	{
		int x, iact=i-1;
		if (iact<13)
		{
			if (iact%2) {
				ans[i][0]=0;
				x=-1;
			} else {
				ans[i][0]=1;
				x=-2;
			}
			for (int j = 1; j <= n; ++j)
			{
				if (j & (int)pow(2, iact)) {
					if ((j & (int)pow(2, iact - 1))) {
						ans[i][j] = iact;
					}
					else {
						ans[i][j] = iact+13;
					}
				}
				else {
					ans[i][j]=x;
				}
			}
		}
		else {
			iact-=13;
			if (iact%2) {
				ans[i][0]=0;
				x=-2;
			} else {
				ans[i][0]=1;
				x=-1;
			}
			for (int j = 1; j <= n; ++j)
			{
				if (j & (int)pow(2, iact)) {
					ans[i][j]=x;
				}
				else {
					if (j & (int)pow(2, iact - 1)) {
						ans[i][j] = iact;
					}
					else {
						ans[i][j] = iact+13;
					}
				}
			}
		}
	}
	return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...