이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "prison.h"
#include <bits/stdc++.h>
using namespace std;
int get_index(int counter, int digit) {
return counter*3 + digit + 1;
}
int get_counter(int index) {
return (index-1)/3;
}
int get_digit(int index) {
return (index-1)%3;
}
int get_num_digit(int num, int counter) {
for (int i = 0; i < counter; i++) {
num /= 3;
}
return num%3;
}
int final_bag(int bag) {
return -(bag+1);
}
vector<vector<int>> devise_strategy(int N) {
int n = 8*3+1;
vector<vector<int>> s(n);
for (int i = 1; i < n; i++) {
s[i].resize(N+1);
int counter = get_counter(i);
int last_digit = get_digit(i);
int bag = counter%2;
//printf("i: %d, counter: %d, last_digit: %d, bag: %d\n", i, counter, last_digit, bag);
s[i][0] = bag;
for (int j = 1; j <= N; j++) {
int digit = get_num_digit(j, counter);
if (digit < last_digit) {
s[i][j] = final_bag(bag);
} else if (last_digit < digit) {
s[i][j] = final_bag(!bag);
} else {
if (counter != 0) {
int new_counter = counter-1;
int new_digit = get_num_digit(j, new_counter);
s[i][j] = get_index(new_counter, new_digit);
//printf("index: %d, new_counter: %d, new_digit: %d\n", s[i][j], new_counter, new_digit);
//printf("%d %d %d\n", s[i][j], new_counter, new_digit);
}
}
}
}
s[0].resize(N+1);
int counter = 7;
int bag = !(counter%2);
s[0][0] = bag;
for (int j = 1; j <= N; j++) {
int digit = get_num_digit(j, counter);
s[0][j] = get_index(counter, digit);
//printf("%d\n", s[0][j]);
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |