답안 #1078402

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1078402 2024-08-27T16:42:26 Z raphaelp Broken Device (JOI17_broken_device) C++14
0 / 100
46 ms 2908 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++)
    {
        Set(i, ans[i]);
    }
}
/*int main()
{
    int 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;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 37 ms 2644 KB Output isn't correct - L* = 0
2 Partially correct 35 ms 2604 KB Output isn't correct - L* = 0
3 Partially correct 36 ms 2776 KB Output isn't correct - L* = 0
4 Partially correct 35 ms 2720 KB Output isn't correct - L* = 0
5 Partially correct 38 ms 2384 KB Output isn't correct - L* = 0
6 Partially correct 34 ms 2744 KB Output isn't correct - L* = 0
7 Partially correct 35 ms 2564 KB Output isn't correct - L* = 0
8 Partially correct 34 ms 2464 KB Output isn't correct - L* = 0
9 Partially correct 37 ms 2628 KB Output isn't correct - L* = 0
10 Partially correct 35 ms 2480 KB Output isn't correct - L* = 0
11 Partially correct 35 ms 2436 KB Output isn't correct - L* = 0
12 Partially correct 36 ms 2576 KB Output isn't correct - L* = 0
13 Partially correct 37 ms 2620 KB Output isn't correct - L* = 0
14 Partially correct 41 ms 2708 KB Output isn't correct - L* = 0
15 Partially correct 36 ms 2652 KB Output isn't correct - L* = 0
16 Partially correct 36 ms 2420 KB Output isn't correct - L* = 0
17 Partially correct 34 ms 2660 KB Output isn't correct - L* = 0
18 Partially correct 46 ms 2628 KB Output isn't correct - L* = 0
19 Partially correct 37 ms 2572 KB Output isn't correct - L* = 0
20 Partially correct 35 ms 2596 KB Output isn't correct - L* = 0
21 Partially correct 40 ms 2876 KB Output isn't correct - L* = 0
22 Partially correct 39 ms 2620 KB Output isn't correct - L* = 0
23 Partially correct 34 ms 2676 KB Output isn't correct - L* = 0
24 Partially correct 35 ms 2624 KB Output isn't correct - L* = 0
25 Partially correct 36 ms 2624 KB Output isn't correct - L* = 0
26 Partially correct 34 ms 2572 KB Output isn't correct - L* = 0
27 Partially correct 41 ms 2576 KB Output isn't correct - L* = 0
28 Partially correct 34 ms 2652 KB Output isn't correct - L* = 0
29 Partially correct 36 ms 2620 KB Output isn't correct - L* = 0
30 Partially correct 35 ms 2664 KB Output isn't correct - L* = 0
31 Partially correct 41 ms 2624 KB Output isn't correct - L* = 0
32 Partially correct 39 ms 2728 KB Output isn't correct - L* = 0
33 Partially correct 36 ms 2664 KB Output isn't correct - L* = 0
34 Partially correct 41 ms 2560 KB Output isn't correct - L* = 0
35 Partially correct 35 ms 2652 KB Output isn't correct - L* = 0
36 Partially correct 37 ms 2612 KB Output isn't correct - L* = 0
37 Partially correct 34 ms 2668 KB Output isn't correct - L* = 0
38 Partially correct 34 ms 2680 KB Output isn't correct - L* = 0
39 Partially correct 35 ms 2908 KB Output isn't correct - L* = 0
40 Partially correct 37 ms 2744 KB Output isn't correct - L* = 0