Submission #869556

#TimeUsernameProblemLanguageResultExecution timeMemory
869556SamurajPrisoner Challenge (IOI22_prison)C++17
65 / 100
16 ms1628 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 += 2; if(n >= 20) ans += 2; return ans; } vector<vector<int>> devise_strategy(int n){ vector<vector<int>> arr(25); //zabrac stany do ktorych nie wejdziemy for(int i = 0; i < 29; i++){ int poz = i%10; int val = i/10; int ind = i-calculate_skip(i); if(i != 0 && (poz == 0 || poz == 9)){ 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; } 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...