제출 #869567

#제출 시각아이디문제언어결과실행 시간메모리
869567Samuraj죄수들의 도전 (IOI22_prison)C++17
80 / 100
13 ms1116 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...