답안 #334903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
334903 2020-12-10T08:02:53 Z dolphingarlic Broken Device (JOI17_broken_device) C++14
100 / 100
52 ms 3048 KB
#include "Annalib.h"

void set(int p, int x) { for (int i = 0; i < 3; i++) Set(p + i, (x >> i) & 1); }

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 > 62 || broken[i] + broken[i + 1] + broken[i + 2] > 1) set(i, 0);
        else if ((!broken[i] && !broken[i + 1] && !broken[i + 2]) || (broken[i + 1] && !(X & (1ll << j)))) {
            if (X & (1ll << j)) {
                if (X & (1ll << j + 1)) set(i, 7);
                else set(i, 3);
            } else {
                if (X & (1ll << j + 1)) set(i, 5);
                else set(i, 4);
            }
            j += 2;
        } else {
            if (!(X & (1ll << j))) set(i, 2);
            else if (broken[i]) set(i, 6);
            else set(i, 1);
            j++;
        }
    }
}
#include "Brunolib.h"

long long Bruno(int N, int A[]) {
    long long ans = 0;
    for (int i = 0, j = 0; i < N; i += 3) {
        int hsh = A[i] + 2 * A[i + 1] + 4 * A[i + 2];
        switch (hsh) {
            case 1:
            case 6:
                ans += 1ll << j;
            case 2:
                j++;
                break;
            case 7:
                ans += 1ll << j;
            case 5:
                ans += 1ll << j + 1;
                j += 2;
                break;
            case 3:
                ans += 1ll << j;
            case 4:
                j += 2;
                break;
        }
    }
    return ans;
}

Compilation message

Anna.cpp: In function 'void Anna(int, long long int, int, int*)':
Anna.cpp:14:35: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   14 |                 if (X & (1ll << j + 1)) set(i, 7);
      |                                 ~~^~~
Anna.cpp:17:35: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   17 |                 if (X & (1ll << j + 1)) set(i, 5);
      |                                 ~~^~~

Bruno.cpp: In function 'long long int Bruno(int, int*)':
Bruno.cpp:17:33: warning: suggest parentheses around '+' inside '<<' [-Wparentheses]
   17 |                 ans += 1ll << j + 1;
      |                               ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 39 ms 2968 KB Output is correct - L* = 40
2 Correct 41 ms 2760 KB Output is correct - L* = 40
3 Correct 39 ms 3016 KB Output is correct - L* = 40
4 Correct 38 ms 2868 KB Output is correct - L* = 40
5 Correct 38 ms 2908 KB Output is correct - L* = 40
6 Correct 40 ms 2872 KB Output is correct - L* = 40
7 Correct 39 ms 2968 KB Output is correct - L* = 40
8 Correct 39 ms 2872 KB Output is correct - L* = 40
9 Correct 38 ms 2976 KB Output is correct - L* = 40
10 Correct 40 ms 2936 KB Output is correct - L* = 40
11 Correct 38 ms 2744 KB Output is correct - L* = 40
12 Correct 38 ms 2968 KB Output is correct - L* = 40
13 Correct 39 ms 2976 KB Output is correct - L* = 40
14 Correct 39 ms 2868 KB Output is correct - L* = 40
15 Correct 38 ms 2976 KB Output is correct - L* = 40
16 Correct 42 ms 2872 KB Output is correct - L* = 40
17 Correct 39 ms 2740 KB Output is correct - L* = 40
18 Correct 39 ms 2992 KB Output is correct - L* = 40
19 Correct 40 ms 2744 KB Output is correct - L* = 40
20 Correct 39 ms 2744 KB Output is correct - L* = 40
21 Correct 38 ms 2740 KB Output is correct - L* = 40
22 Correct 45 ms 2740 KB Output is correct - L* = 40
23 Correct 38 ms 2868 KB Output is correct - L* = 40
24 Correct 40 ms 3032 KB Output is correct - L* = 40
25 Correct 40 ms 2976 KB Output is correct - L* = 40
26 Correct 39 ms 2872 KB Output is correct - L* = 40
27 Correct 39 ms 2968 KB Output is correct - L* = 40
28 Correct 39 ms 2740 KB Output is correct - L* = 40
29 Correct 38 ms 2868 KB Output is correct - L* = 40
30 Correct 52 ms 2744 KB Output is correct - L* = 40
31 Correct 41 ms 2888 KB Output is correct - L* = 40
32 Correct 39 ms 2872 KB Output is correct - L* = 40
33 Correct 41 ms 3048 KB Output is correct - L* = 40
34 Correct 38 ms 2868 KB Output is correct - L* = 40
35 Correct 39 ms 2744 KB Output is correct - L* = 40
36 Correct 39 ms 2968 KB Output is correct - L* = 40
37 Correct 41 ms 2872 KB Output is correct - L* = 40
38 Correct 40 ms 2740 KB Output is correct - L* = 40
39 Correct 39 ms 2868 KB Output is correct - L* = 40
40 Correct 39 ms 2872 KB Output is correct - L* = 40