Submission #705301

#TimeUsernameProblemLanguageResultExecution timeMemory
705301danikoynov죄수들의 도전 (IOI22_prison)C++17
36.50 / 100
26 ms1612 KiB
#include "prison.h"

#include <bits/stdc++.h>
using namespace std;


int get_mask(int type, int bit)
{
    return type * 13 + bit;
}
vector<std::vector<int>> devise_strategy(int N)
{
    vector < vector < int > > strategy;
    int maxnum = 39;
    strategy.resize(maxnum + 1);
    for (int i = 0; i <= maxnum; i ++)
        strategy[i].resize(N + 1);
    strategy[0][0] = 0;
    for (int j = 1; j <= N; j ++)
    {
        if ((j & (1 << 12)))
            strategy[0][j] = get_mask(0, 13);
        else
            strategy[0][j] = get_mask(1, 13);
    }
    /**for (int j = 1; j <= N; j ++)
        cout << strategy[0][j] << " ";
    cout << endl;*/
    for (int i = 1; i <= maxnum; i ++)
    {
        int type = (i - 1) / 13, bit = (i - type * 13) - 1;
        if (type == 2)
        {
            strategy[i][0] = 0;
            bit --;
            for (int j = 1; j <= N; j ++)
            {
                if ((j & (1 << bit)))
                    strategy[i][j] = get_mask(0, bit + 1);
                else
                    strategy[i][j] = get_mask(1, bit + 1);
            }
        }
        else
        {
            strategy[i][0] = 1;
            for (int j = 1; j <= N; j ++)
            {
                if ((j & (1 << bit)))
                {
                    if (type == 1)
                    {
                        strategy[i][j] = -1;
                    }
                    else
                        strategy[i][j] = get_mask(2, bit + 1);
                }
                else
                {
                    if (type == 0)
                    {
                        strategy[i][j] = -2;
                    }
                    else
                        strategy[i][j] = get_mask(2, bit + 1);
                }
            }
        }
    }
    return strategy;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...