답안 #334257

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
334257 2020-12-08T19:42:49 Z dolphingarlic Broken Device (JOI17_broken_device) C++14
51 / 100
54 ms 3144 KB
#include "Annalib.h"

void Anna(int N, long long X, int K, int P[]) {
    bool broken[150];
    for (int i = 0; i < N; i++) broken[i] = false;
    for (int i = 0; i < K; i++) broken[P[i]] = true;

    for (int i = 0, j = 0; i < N; i += 3) {
        if (j > 60) Set(i, 0), Set(i + 1, 0), Set(i + 2, 0);
        else if (!broken[i] && !broken[i + 1] && !broken[i + 2]) {
            Set(i, 1);
            Set(i + 1, (X & (1ll << j)) >> j);
            Set(i + 2, (X & (1ll << j + 1)) >> j + 1);
            j += 2;
        } else if ((X & (1ll << j)) && !broken[i + 1] && !broken[i + 2]) {
            Set(i, 0), Set(i + 1, 1), Set(i + 2, 1);
            j++;
        } else if (!(X & (1ll << j)) && (!broken[i + 1] || !broken[i + 2])) {
            Set(i, 0);
            if (!broken[i + 1]) Set(i + 1, 1), Set(i + 2, 0);
            else Set(i + 1, 0), Set(i + 2, 1);
            j++;
        } else Set(i, 0), Set(i + 1, 0), Set(i + 2, 0);
    }
}
#include "Brunolib.h"

long long Bruno(int N, int A[]) {
    long long ans = 0;
    for (int i = 0, j = 0; i < N && j <= 60; i += 3) {
        if (A[i]) {
            ans += A[i + 1] * (1ll << j) + A[i + 2] * (1ll << j + 1);
            j += 2;
        } else if (A[i + 1] || A[i + 2]) {
            ans += (A[i + 1] + A[i + 2] - 1) * (1ll << j);
            j++;
        }
    }
    return ans;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:13:39: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   13 |             Set(i + 2, (X & (1ll << j + 1)) >> j + 1);
      |                                     ~~^~~
Anna.cpp:13:50: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   13 |             Set(i + 2, (X & (1ll << j + 1)) >> j + 1);
      |                                                ~~^~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:7:65: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
    7 |             ans += A[i + 1] * (1ll << j) + A[i + 2] * (1ll << j + 1);
      |                                                               ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Partially correct 39 ms 2840 KB Output is partially correct - L* = 23
2 Partially correct 40 ms 2896 KB Output is partially correct - L* = 20
3 Partially correct 40 ms 2868 KB Output is partially correct - L* = 21
4 Partially correct 39 ms 3008 KB Output is partially correct - L* = 21
5 Partially correct 39 ms 2744 KB Output is partially correct - L* = 20
6 Partially correct 43 ms 2872 KB Output is partially correct - L* = 20
7 Partially correct 39 ms 2968 KB Output is partially correct - L* = 22
8 Partially correct 39 ms 2744 KB Output is partially correct - L* = 21
9 Partially correct 39 ms 2744 KB Output is partially correct - L* = 20
10 Partially correct 39 ms 2872 KB Output is partially correct - L* = 23
11 Partially correct 40 ms 3104 KB Output is partially correct - L* = 22
12 Partially correct 54 ms 2968 KB Output is partially correct - L* = 22
13 Partially correct 40 ms 2744 KB Output is partially correct - L* = 21
14 Partially correct 39 ms 2968 KB Output is partially correct - L* = 20
15 Partially correct 40 ms 3096 KB Output is partially correct - L* = 20
16 Partially correct 46 ms 2744 KB Output is partially correct - L* = 21
17 Partially correct 46 ms 2968 KB Output is partially correct - L* = 20
18 Partially correct 39 ms 2976 KB Output is partially correct - L* = 20
19 Partially correct 40 ms 2744 KB Output is partially correct - L* = 22
20 Partially correct 40 ms 2968 KB Output is partially correct - L* = 21
21 Partially correct 41 ms 2740 KB Output is partially correct - L* = 20
22 Partially correct 41 ms 2916 KB Output is partially correct - L* = 20
23 Partially correct 39 ms 2868 KB Output is partially correct - L* = 20
24 Partially correct 40 ms 2756 KB Output is partially correct - L* = 22
25 Partially correct 39 ms 2976 KB Output is partially correct - L* = 21
26 Partially correct 39 ms 2968 KB Output is partially correct - L* = 21
27 Partially correct 40 ms 2744 KB Output is partially correct - L* = 22
28 Partially correct 39 ms 2740 KB Output is partially correct - L* = 21
29 Partially correct 46 ms 2976 KB Output is partially correct - L* = 20
30 Partially correct 40 ms 2976 KB Output is partially correct - L* = 20
31 Partially correct 49 ms 2916 KB Output is partially correct - L* = 21
32 Partially correct 45 ms 2892 KB Output is partially correct - L* = 20
33 Partially correct 41 ms 3132 KB Output is partially correct - L* = 20
34 Partially correct 39 ms 3016 KB Output is partially correct - L* = 22
35 Partially correct 44 ms 3096 KB Output is partially correct - L* = 20
36 Partially correct 38 ms 2744 KB Output is partially correct - L* = 21
37 Partially correct 41 ms 3144 KB Output is partially correct - L* = 20
38 Partially correct 39 ms 2968 KB Output is partially correct - L* = 22
39 Partially correct 39 ms 2740 KB Output is partially correct - L* = 21
40 Partially correct 50 ms 2940 KB Output is partially correct - L* = 21