답안 #1029804

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1029804 2024-07-21T10:49:55 Z borisAngelov Broken Device (JOI17_broken_device) C++17
41 / 100
25 ms 3276 KB
#include "Annalib.h"
#include <bits/stdc++.h>

using namespace std;

void Anna(int N, long long X, int K, int P[])
{
    int n = N;
    long long x = X;
    int k = K;

    bool isBlocked[n + 1] = {};

    for (int i = 0; i < n; ++i)
    {
        isBlocked[i] = false;
    }

    for (int i = 0; i < k; ++i)
    {
        isBlocked[P[i]] = true;
    }

    long long bit = 0;

    for (int i = 0; i < n; ++i)
    {
        if (bit == 60)
        {
            Set(i, 0);
            continue;
        }

        if (i < n - 1 && (x & (1LL << bit)) == 0 && isBlocked[i + 1] == false)
        {
            Set(i, 0);
            Set(i + 1, 1);
            ++i;
            ++bit;
            continue;
        }

        if (i < n - 1 && isBlocked[i] == false && isBlocked[i + 1] == false)
        {
            if ((x & (1LL << bit)) != 0)
            {
                Set(i, 1);
            }
            else
            {
                Set(i, 0);
            }

            Set(i + 1, 1);
            ++i;
            ++bit;
        }
        else
        {
            Set(i, 0);
        }
    }
}
#include "Brunolib.h"
#include <bits/stdc++.h>

using namespace std;

long long Bruno(int N, int A[])
{
    int n = N;
    int a[n + 1] = {};

    for (int i = 0; i < n; ++i)
    {
        a[i] = A[i];
    }

    /*for (int i = 0; i < n; ++i)
    {
        cout << a[i] << " ";
    }

    cout << endl;*/

    long long ans = 0;
    long long bit = 0;

    for (int i = 0; i < n; ++i)
    {
        if (a[i] == 1)
        {
            int cnt = 1, from = i;

            while (i + 1 < n && a[i + 1] == 1)
            {
                ++cnt;
                ++i;
            }

            if (cnt % 2 == 1)
            {
                ++from;
                ++bit;
            }

            for (int j = from; j <= i; j += 2)
            {
                ans += (1LL << bit);
                ++bit;
            }

            //cout << from << " " << i << " :: " << ans << endl;
        }
    }

    //cout << ans << endl;

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 20 ms 2784 KB Output is partially correct - L* = 17
2 Partially correct 20 ms 2948 KB Output is partially correct - L* = 16
3 Partially correct 20 ms 2768 KB Output is partially correct - L* = 18
4 Partially correct 20 ms 2772 KB Output is partially correct - L* = 17
5 Partially correct 20 ms 2776 KB Output is partially correct - L* = 17
6 Partially correct 24 ms 2776 KB Output is partially correct - L* = 17
7 Partially correct 23 ms 2772 KB Output is partially correct - L* = 18
8 Partially correct 20 ms 2764 KB Output is partially correct - L* = 18
9 Partially correct 20 ms 2776 KB Output is partially correct - L* = 18
10 Partially correct 20 ms 2752 KB Output is partially correct - L* = 16
11 Partially correct 20 ms 2776 KB Output is partially correct - L* = 17
12 Partially correct 20 ms 2856 KB Output is partially correct - L* = 20
13 Partially correct 20 ms 2752 KB Output is partially correct - L* = 18
14 Partially correct 20 ms 2772 KB Output is partially correct - L* = 18
15 Partially correct 20 ms 2768 KB Output is partially correct - L* = 16
16 Partially correct 20 ms 2776 KB Output is partially correct - L* = 17
17 Partially correct 20 ms 2768 KB Output is partially correct - L* = 17
18 Partially correct 20 ms 2968 KB Output is partially correct - L* = 16
19 Partially correct 24 ms 2784 KB Output is partially correct - L* = 18
20 Partially correct 23 ms 2776 KB Output is partially correct - L* = 15
21 Partially correct 20 ms 2768 KB Output is partially correct - L* = 17
22 Partially correct 22 ms 2864 KB Output is partially correct - L* = 16
23 Partially correct 20 ms 2772 KB Output is partially correct - L* = 15
24 Partially correct 20 ms 2776 KB Output is partially correct - L* = 17
25 Partially correct 20 ms 2776 KB Output is partially correct - L* = 21
26 Partially correct 24 ms 2684 KB Output is partially correct - L* = 16
27 Partially correct 23 ms 2776 KB Output is partially correct - L* = 18
28 Partially correct 25 ms 2748 KB Output is partially correct - L* = 19
29 Partially correct 23 ms 2780 KB Output is partially correct - L* = 16
30 Partially correct 25 ms 2752 KB Output is partially correct - L* = 20
31 Partially correct 20 ms 2780 KB Output is partially correct - L* = 17
32 Partially correct 18 ms 2772 KB Output is partially correct - L* = 18
33 Partially correct 20 ms 2768 KB Output is partially correct - L* = 17
34 Partially correct 20 ms 3276 KB Output is partially correct - L* = 18
35 Partially correct 20 ms 2776 KB Output is partially correct - L* = 16
36 Partially correct 20 ms 2776 KB Output is partially correct - L* = 15
37 Partially correct 20 ms 2780 KB Output is partially correct - L* = 16
38 Partially correct 20 ms 2768 KB Output is partially correct - L* = 18
39 Partially correct 20 ms 2772 KB Output is partially correct - L* = 17
40 Partially correct 23 ms 2752 KB Output is partially correct - L* = 15