답안 #1078416

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078416 2024-08-27T16:55:59 Z raphaelp Broken Device (JOI17_broken_device) C++14
0 / 100
2 ms 1292 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 Incorrect 0 ms 792 KB Wrong Answer [4]
2 Incorrect 0 ms 780 KB Wrong Answer [4]
3 Incorrect 1 ms 784 KB Wrong Answer [4]
4 Incorrect 1 ms 796 KB Wrong Answer [4]
5 Incorrect 0 ms 788 KB Wrong Answer [4]
6 Incorrect 0 ms 780 KB Wrong Answer [4]
7 Incorrect 0 ms 784 KB Wrong Answer [4]
8 Incorrect 0 ms 792 KB Wrong Answer [4]
9 Incorrect 0 ms 788 KB Wrong Answer [4]
10 Incorrect 0 ms 796 KB Wrong Answer [4]
11 Incorrect 1 ms 792 KB Wrong Answer [4]
12 Incorrect 0 ms 796 KB Wrong Answer [4]
13 Incorrect 1 ms 800 KB Wrong Answer [4]
14 Incorrect 0 ms 796 KB Wrong Answer [4]
15 Incorrect 0 ms 784 KB Wrong Answer [4]
16 Incorrect 1 ms 796 KB Wrong Answer [4]
17 Incorrect 1 ms 796 KB Wrong Answer [4]
18 Incorrect 2 ms 796 KB Wrong Answer [4]
19 Incorrect 1 ms 1292 KB Wrong Answer [4]
20 Incorrect 1 ms 780 KB Wrong Answer [4]
21 Incorrect 0 ms 796 KB Wrong Answer [4]
22 Incorrect 0 ms 784 KB Wrong Answer [4]
23 Incorrect 0 ms 796 KB Wrong Answer [4]
24 Incorrect 0 ms 800 KB Wrong Answer [4]
25 Incorrect 0 ms 792 KB Wrong Answer [4]
26 Incorrect 0 ms 784 KB Wrong Answer [4]
27 Incorrect 0 ms 780 KB Wrong Answer [4]
28 Incorrect 2 ms 796 KB Wrong Answer [4]
29 Incorrect 0 ms 792 KB Wrong Answer [4]
30 Incorrect 0 ms 796 KB Wrong Answer [4]
31 Incorrect 0 ms 792 KB Wrong Answer [4]
32 Incorrect 1 ms 792 KB Wrong Answer [4]
33 Incorrect 0 ms 796 KB Wrong Answer [4]
34 Incorrect 1 ms 784 KB Wrong Answer [4]
35 Incorrect 0 ms 796 KB Wrong Answer [4]
36 Incorrect 1 ms 796 KB Wrong Answer [4]
37 Incorrect 1 ms 796 KB Wrong Answer [4]
38 Incorrect 0 ms 800 KB Wrong Answer [4]
39 Incorrect 0 ms 796 KB Wrong Answer [4]
40 Incorrect 0 ms 784 KB Wrong Answer [4]