Submission #869567

# Submission time Handle Problem Language Result Execution time Memory
869567 2023-11-04T18:28:58 Z Samuraj Prisoner Challenge (IOI22_prison) C++17
80 / 100
13 ms 1116 KB
#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
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 344 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 2 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Partially correct 0 ms 348 KB Output is partially correct
3 Partially correct 0 ms 348 KB Output is partially correct
4 Partially correct 6 ms 860 KB Output is partially correct
5 Partially correct 11 ms 1116 KB Output is partially correct
6 Partially correct 13 ms 1116 KB Output is partially correct
7 Partially correct 13 ms 1116 KB Output is partially correct
8 Partially correct 0 ms 348 KB Output is partially correct
9 Partially correct 1 ms 348 KB Output is partially correct
10 Partially correct 2 ms 544 KB Output is partially correct
11 Partially correct 6 ms 604 KB Output is partially correct
12 Partially correct 10 ms 1024 KB Output is partially correct