답안 #1078417

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078417 2024-08-27T16:57:35 Z raphaelp Broken Device (JOI17_broken_device) C++14
0 / 100
60 ms 3404 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

void Anna(int N, long long X, int K, int P[])
{
    vector<int> bits;
    while (X)
    {
        bits.push_back(X % 2);
        X /= 2;
    }
    int M = bits.size();
    reverse(bits.begin(), bits.end());
    vector<vector<pair<int, int>>> dp(N + 5, vector<pair<int, int>>(M + 1));
    vector<int> ans(N);
    dp[0][0].first = 1;
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < M; j++)
        {
            if (dp[i][j].first)
            {
                dp[i + 1][j].first = 1;
                if (bits[j] == 0 && P[i] == 0)
                {
                    dp[i + 2][j + 1].first = 2;
                }
                if (bits[j] == 1 && i < N - 1 && P[i] == 0 && P[i + 1] == 0)
                {
                    dp[i + 3][j + 1].first = 3;
                }
                if (i < N - 2 && P[i] == 0 && P[i + 1] == 0 && P[i + 2] == 0)
                {
                    dp[i + 4][j].second = 4;
                }
            }
            if (dp[i][j].second)
            {
                dp[i + 1][j].second = 1;
                if (bits[j] == 1 && P[i] == 0)
                {
                    dp[i + 2][j + 1].second = 2;
                }
                if (bits[j] == 0 && i < N - 1 && P[i] == 0 && P[i + 1] == 0)
                {
                    dp[i + 3][j + 1].second = 3;
                }
                if (i < N - 2 && P[i] == 0 && P[i + 1] == 0 && P[i + 2] == 0)
                {
                    dp[i + 4][j].first = 4;
                }
            }
        }
    }
    int x = N + 1;
    while (true)
    {
        if (x == -1)
            break;
        if (dp[x][M].first)
            break;
        if (dp[x][M].second)
        {
            x += 200;
            break;
        }
        x--;
    }
    int y = M;
    while (x > 0)
    {
        if (x >= 200)
        {
            x -= 200;
            int temp = dp[x][y].second;
            x--;
            for (int i = 1; i < temp; i++)
            {
                x--;
                ans[x] = 1;
            }
            if (temp == 2 || temp == 3)
                y--;
            if (temp < 4)
                x += 200;
        }
        else
        {
            int temp = dp[x][y].first;
            x--;
            for (int i = 1; i < temp; i++)
            {
                x--;
                ans[x] = 1;
            }
            if (temp == 2 || temp == 3)
                y--;
            if (temp == 4)
                x += 200;
        }
    }
    for (int i = 0; i < N; i++)
    {
        cout << ans[i] << ' ';
        Set(i, ans[i]);
    }
}
/*int main()
{
    long long N, X, K;
    cin >> N >> X >> K;
    int P[N];
    for (int i = 0; i < N; i++)
        P[i] = 0;
    for (int i = 0; i < K; i++)
    {
        int x;
        cin >> x;
        P[x] = 1;
    }
    Anna(N, X, K, P);
}*/
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;
long long Bruno(int N, int A[])
{
    long long X = 0;
    int cur = 0;
    int mult = 1;
    for (int i = 0; i < N; i++)
    {
        if (A[i])
            cur++;
        else
        {
            if (cur)
            {
                if (cur == 3)
                    mult = 1 - mult;
                if (cur == 2)
                {
                    X *= 2;
                    X += mult;
                }
                if (cur == 1)
                {
                    X *= 2;
                    X += 1 - mult;
                }
            }
            cur = 0;
        }
    }
    if (cur)
    {
        if (cur == 3)
            mult = 1 - mult;
        if (cur == 2)
        {
            X *= 2;
            X += mult;
        }
        if (cur == 1)
        {
            X *= 2;
            X += 1 - mult;
        }
    }
    return X;
}
/*int main()
{
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; i++)
        cin >> A[i];
    cout << Bruno(N, A);
}*/
# 결과 실행 시간 메모리 Grader output
1 Runtime error 40 ms 3108 KB Execution killed with signal 11
2 Runtime error 40 ms 3132 KB Execution killed with signal 11
3 Runtime error 40 ms 3112 KB Execution killed with signal 11
4 Runtime error 40 ms 3116 KB Execution killed with signal 11
5 Runtime error 42 ms 3404 KB Execution killed with signal 11
6 Runtime error 41 ms 3112 KB Execution killed with signal 11
7 Runtime error 39 ms 3108 KB Execution killed with signal 11
8 Runtime error 39 ms 3188 KB Execution killed with signal 11
9 Runtime error 47 ms 3392 KB Execution killed with signal 11
10 Runtime error 40 ms 3124 KB Execution killed with signal 11
11 Runtime error 40 ms 3140 KB Execution killed with signal 11
12 Runtime error 42 ms 3056 KB Execution killed with signal 11
13 Runtime error 41 ms 3188 KB Execution killed with signal 11
14 Runtime error 40 ms 3052 KB Execution killed with signal 11
15 Runtime error 42 ms 3008 KB Execution killed with signal 11
16 Runtime error 41 ms 3292 KB Execution killed with signal 11
17 Runtime error 45 ms 3220 KB Execution killed with signal 11
18 Runtime error 39 ms 3376 KB Execution killed with signal 11
19 Runtime error 42 ms 3128 KB Execution killed with signal 11
20 Runtime error 40 ms 3180 KB Execution killed with signal 11
21 Runtime error 41 ms 3188 KB Execution killed with signal 11
22 Runtime error 39 ms 3108 KB Execution killed with signal 11
23 Runtime error 41 ms 3224 KB Execution killed with signal 11
24 Runtime error 40 ms 3188 KB Execution killed with signal 11
25 Runtime error 40 ms 3188 KB Execution killed with signal 11
26 Runtime error 41 ms 3176 KB Execution killed with signal 11
27 Runtime error 41 ms 3044 KB Execution killed with signal 11
28 Runtime error 40 ms 3180 KB Execution killed with signal 11
29 Runtime error 58 ms 3128 KB Execution killed with signal 11
30 Runtime error 60 ms 3132 KB Execution killed with signal 11
31 Runtime error 42 ms 3180 KB Execution killed with signal 11
32 Runtime error 43 ms 3108 KB Execution killed with signal 11
33 Runtime error 47 ms 3140 KB Execution killed with signal 11
34 Runtime error 41 ms 3128 KB Execution killed with signal 11
35 Runtime error 41 ms 3108 KB Execution killed with signal 11
36 Runtime error 40 ms 3124 KB Execution killed with signal 11
37 Runtime error 49 ms 3164 KB Execution killed with signal 11
38 Runtime error 40 ms 3208 KB Execution killed with signal 11
39 Runtime error 39 ms 3112 KB Execution killed with signal 11
40 Runtime error 40 ms 3148 KB Execution killed with signal 11