제출 #1267036

#제출 시각아이디문제언어결과실행 시간메모리
1267036silentloop죄수들의 도전 (IOI22_prison)C++20
10 / 100
3 ms836 KiB
#include <bits/stdc++.h>
#define ll long long
#define sz(x) int(x.size())
#define forn(i, n) for (i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define fr first
#define se second
using namespace std;

std::vector<std::vector<int>> devise_strategy(int N)
{
    vector<vector<int>> ans(25, vector<int>(N + 1, 0));
    ll i, j, act = 1, bit = 12, aBit = 12, aJ = 1, sig=3;
    ans[0][0] = 0;
    for (i = 1; i < 25; i += 2)
    {
        ans[i][0] = act;
        ans[i + 1][0] = act;
        if (act == 1)
            act = 0;
        else
            act = 1;
    }
    for (j = 1; j <= N; j++)
        ans[0][j] = ((1 << bit) & j) + 1;
    bit--;
    for (i = 1; i < 25; i++)
    {
        for (j = 1; j <= N; j++)
        {
            if (bool((1 << aBit) & j) > ((i + 1) % 2))
            {
                ans[i][j] = -aJ;
            }
            else if (bool((1 << aBit) & j) < ((i + 1) % 2))
            {
                if (aJ == 1)
                    ans[i][j] = -2;
                else
                    ans[i][j] = -1;
            }
            else
            {
                if(((1 << bit) & j))
                    ans[i][j]=sig+1;
                else
                    ans[i][j]=sig;
            }
        }
        if (i % 2 == 0)
        {
            aBit=bit;
            sig+=2;
            bit--;
            if (aJ == 1)
                aJ = 2;
            else
                aJ = 1;
        }
    }
    for (j = 1; j <= N; j++)
    {
        if(ans[23][j]>=25)
        {
            if(j&1)
                ans[23][j]=-(ans[22][0]+1);
            else
                ans[23][j]=-(ans[23][0]+1);
        }
        if(ans[24][j]>=25)
        {
            if(j&1)
                ans[24][j]=-(ans[22][0]+1);
            else
                ans[24][j]=-(ans[24][0]+1);
        }
    }
    /*for (i = 0; i < sz(ans); i++)
    {
        cout << i << ": ";
        for (ll j = 0; j < sz(ans[i]); j++)
        {
            cout << ans[i][j] << ' ';
        }
        cout << '\n';
    }*/
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...