이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
//#include "prison.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<ll,ll> pl;
const int max_pow = 2187;
int get_ter(int n, int poz){
//max 8 miejsc
int pow = max_pow;
int ans = 0;
while(pow > 0 && poz > 0){
ans = n/pow;
n -= ans*pow;
poz--;
pow /= 3;
}
return ans;
}
int calculate_skip(int n){
int ans = 0;
if(n >= 10) ans += 3;
if(n >= 20) ans += 2;
return ans;
}
vector<vector<int>> devise_strategy(int n){
vector<vector<int>> arr(23);
//zabrac stany do ktorych nie wejdziemy
for(int i = 0; i <= 27; i++){
int poz = i%10;
int val = i/10;
int ind = i-calculate_skip(i);
if(i != 0 && (poz == 0 || poz == 9)){
continue;
}
if(i == 8) continue;
//check left
if(poz%2 == 0) arr[ind].push_back(0);
else arr[ind].push_back(1);
for(int j = 1; j <= n; j++){
//start
int check = get_ter(j,poz);
int write = get_ter(j,poz+1);
if(i == 0){
int val = write*10+poz+1;
arr[ind].push_back(val-calculate_skip(val));
continue;
}
//fewer coins
if(check < val)//pierwsza torba
arr[ind].push_back((arr[ind][0] == 0 ? -1 : -2));
else if(check > val)//druga torba
arr[ind].push_back((arr[ind][0] == 0 ? -2 : -1));
else{
//obojetnie, nie bedzie takiej sytuacji
if(poz == 8){
arr[ind].push_back(-1);
continue;
}
if(poz == 7 && write != 1){
//checkujemy B
if(write == 2) arr[ind].push_back(-1);
if(write == 0) arr[ind].push_back(-2);
continue;
}
int val = write*10+poz+1;
arr[ind].push_back(val-calculate_skip(val));
}
}
}
return arr;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |