Submission #954393

# Submission time Handle Problem Language Result Execution time Memory
954393 2024-03-27T18:37:38 Z n1k Prisoner Challenge (IOI22_prison) C++17
0 / 100
1 ms 348 KB
#include "prison.h"
#include <bits/stdc++.h>

using namespace std;

std::vector<std::vector<int>> devise_strategy(int N) {
	int states = 24-1;

	vector v(states, vector<int>(N+1));

	auto get_trit = [&](auto num, auto stelle){
		for(int k=0; k<7-stelle; k++){
			num /= 3;
		}
		return num % 3;
	};


	for(int x=0; x<=states; x++){
		int stelle = (x-1)%8;
		int o_trit = (x-1)/8;
		int is_b = stelle%2;

		if(x==0)
			v[x][0] = 1;
		else
			v[x][0] = is_b;

		for(int j=0; j<N; j++){
			if(x==0){
				v[x][j+1] = 1 + 8 * get_trit(j, 0);
			}else{
				if(get_trit(j, stelle) == o_trit){
					int ntrit = get_trit(j, stelle+1);
					if(stelle==6 and (ntrit == 0 or ntrit == 2)){
						v[x][j+1] = is_b^(ntrit==0) ? -1 : -2;
					}else{
						v[x][j+1] = 8 * ntrit + stelle + 2;
					}
				}else{
					v[x][j+1] = is_b^(get_trit(j, stelle)<o_trit) ? -1 : -2;
				}
			}
		}
	}

	for(int i=0; i<=states; i++){
		for(int j=0; j<N; j++){
			v[i][j] = min(v[i][j], states);
		}
	}

	// redundant (stelle 7, trit 1)
	// redundant (stelle 7, trit 2)

	/*
	for(int i=0; i<v.size(); i++){
		for(int j=0; j<v[i].size(); j++)
			cout << v[i][j] << " ";
		cout << endl;
	}
	cout << endl;
	*/

	return v;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -