Submission #727952

#TimeUsernameProblemLanguageResultExecution timeMemory
727952aykhnPrisoner Challenge (IOI22_prison)C++17
0 / 100
1 ms212 KiB
#include <bits/stdc++.h>
#include "prison.h"

/*
    author: aykhn
    4/21/2023
*/

using namespace std;

typedef long long ll;

#define OPT ios_base::sync_with_stdio(0); \
            cin.tie(0); \
            cout.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()
#define mpr make_pair
#define pb push_back
#define ts to_string
#define fi first
#define se second
#define inf 0x3F3F3F3F
#define infll 0x3F3F3F3F3F3F3F3FLL
#define bpc __builtin_popcount
#define print(v) for(int i = 0; i < v.size(); i++) cout << v[i] << " "; cout<<endl;
/*
    notes:
        divide the bits into consecutive pairs
        00 -> 0 = x
        01 -> 1 = x
        10 -> 2 = x
        11 -> 3 = x

        can be look as ab where a = 2 and b = 1 so when turned on += them

        on whiteboard: x*10 + group number

        max group number = lg(MAX)/2 + 1 = lg(5000)/2 + 1 ~~ 12/2 + 1 = 7

        max X = 36 (max 1st group = 1 so 17, 36)

        25 + 1.5*3 + 10 = 36 points
*/

vector<vector<int>> devise_strategy(int n)
{
    vector<vector<int>> s(37, vector<int> (n + 1, 0));

    s[0][0] = 0;
    for (int i = 1; i <= n; i++) s[0][i] = ((i >> 12) & 1)*10 + 6;

    for (int i = 0; i <= 1; i++)
    {
        s[i*10 + 7][0] = 1;
        for (int j = 1; j <= n; j++)
        {
            if (((j >> 12) & 1) > i) s[i*10 + 7][j] = -1;
            else if (((j >> 12) & 1) < i) s[i*10 + 7][j] = -2;
            else s[i*10 + 7][j] = (((j >> 11) & 1)*2 + ((j >> 10) & 1))*10 + 6;
        }
    }

    for (int i = 0; i <= 3; i++)
    {
        for (int k = 1; k <= 6; k++)
        {
            s[i*10 + k][0] = k % 2;

            int w = k%2 - 2;

            for (int j = 1; j <= n; j++)
            {
                int x = ((j >> (2*k - 1)) & 1)*2 + ((j >> (2*k - 2)) & 1);
                int y = 0;
                if (k > 1) y = ((j >> (2*k - 3)) & 1)*2 + ((j >> (2*k - 4)) & 1);
                if (x < i) s[i*10 + k][j] = w;
                else if (x > i) s[i*10 + k][j] = w + 1;
                else if (k > 1) s[i*10 + k][j] = y*10 + k - 1;
            }
        }
    }

    return s;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...