답안 #289047

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
289047 2020-09-02T10:01:58 Z fishy15 Broken Device (JOI17_broken_device) C++14
100 / 100
73 ms 3144 KB
#include "Annalib.h"
#include <vector>
using namespace std;

void Anna(int N, long long X, int K, int P[]) {
    vector<bool> works(N, true);
    vector<bool> toset(N, false);
    
    for (int i = 0; i < K; i++) {
        works[P[i]] = false;
    }

    for (int i = 0; i < N; i += 3) {
        int cnt = works[i] + works[i + 1] + works[i + 2];
        if (cnt == 3) {
            int v = X % 4;
            if (v == 0) {
                toset[i] = 1;
            } else if (v == 1) {
                toset[i + 1] = 1;
                toset[i + 2] = 1;
            } else if (v == 2) {
                toset[i] = 1;
                toset[i + 2] = 1;
            } else {
                toset[i] = 1;
                toset[i + 1] = 1;
                toset[i + 2] = 1;
            }
            X >>= 2;
        } else if (cnt == 2) {
            if (!works[i]) {
                if (X & 1) {
                    toset[i + 2] = 1;
                } else {
                    toset[i + 1] = 1;
                }
                X >>= 1;
            } else if (!works[i + 1]) {
                if (X & 1) {
                    toset[i + 2] = 1;
                    X >>= 1;
                } else {
                    if (X % 4 == 0) {
                        toset[i] = 1;
                    } else {
                        toset[i] = 1;
                        toset[i + 2] = 1;
                    }
                    X >>= 2;
                }
            } else {
                if (X & 1) {
                    toset[i] = 1;
                    toset[i + 1] = 1;
                } else {
                    toset[i + 1] = 1;
                }
                X >>= 1;
            }
        }
    }

    for (int i = 0; i < N; i++) {
        Set(i, toset[i]);
    }
}
#include "Brunolib.h"
#define ll long long

long long Bruno(int N, int A[]){
    int d = 0;
    ll ans = 0;

    for (int i = 0; i < N; i += 3) {
        if (d > 60) break;
        int v = 4 * A[i] + 2 * A[i + 1] + A[i + 2];
        if (v == 1) {
            ans += 1LL << d;
            d++;
        } else if (v == 2) {
            d++;
        } else if (v == 3) {
            ans += 1LL << d;
            d += 2;
        } else if (v == 4) {
            d += 2;
        } else if (v == 5) {
            ans += 2LL << d;
            d += 2;
        } else if (v == 6) {
            ans += 1LL << d;
            d++;
        } else if (v == 7) {
            ans += 3LL << d;
            d += 2;
        }
    }

    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 3056 KB Output is correct - L* = 40
2 Correct 73 ms 3072 KB Output is correct - L* = 40
3 Correct 45 ms 3072 KB Output is correct - L* = 40
4 Correct 43 ms 3064 KB Output is correct - L* = 40
5 Correct 41 ms 3072 KB Output is correct - L* = 40
6 Correct 42 ms 3056 KB Output is correct - L* = 40
7 Correct 46 ms 3072 KB Output is correct - L* = 40
8 Correct 43 ms 3056 KB Output is correct - L* = 40
9 Correct 44 ms 2888 KB Output is correct - L* = 40
10 Correct 50 ms 3072 KB Output is correct - L* = 40
11 Correct 41 ms 3056 KB Output is correct - L* = 40
12 Correct 56 ms 3072 KB Output is correct - L* = 40
13 Correct 45 ms 3072 KB Output is correct - L* = 40
14 Correct 42 ms 3072 KB Output is correct - L* = 40
15 Correct 47 ms 3072 KB Output is correct - L* = 40
16 Correct 48 ms 3144 KB Output is correct - L* = 40
17 Correct 46 ms 3072 KB Output is correct - L* = 40
18 Correct 41 ms 3072 KB Output is correct - L* = 40
19 Correct 49 ms 3072 KB Output is correct - L* = 40
20 Correct 41 ms 3072 KB Output is correct - L* = 40
21 Correct 44 ms 3072 KB Output is correct - L* = 40
22 Correct 41 ms 3056 KB Output is correct - L* = 40
23 Correct 41 ms 3072 KB Output is correct - L* = 40
24 Correct 41 ms 3056 KB Output is correct - L* = 40
25 Correct 43 ms 3072 KB Output is correct - L* = 40
26 Correct 66 ms 3072 KB Output is correct - L* = 40
27 Correct 64 ms 3056 KB Output is correct - L* = 40
28 Correct 44 ms 3056 KB Output is correct - L* = 40
29 Correct 41 ms 3072 KB Output is correct - L* = 40
30 Correct 41 ms 3072 KB Output is correct - L* = 40
31 Correct 43 ms 3056 KB Output is correct - L* = 40
32 Correct 41 ms 3056 KB Output is correct - L* = 40
33 Correct 45 ms 3056 KB Output is correct - L* = 40
34 Correct 45 ms 3072 KB Output is correct - L* = 40
35 Correct 44 ms 3072 KB Output is correct - L* = 40
36 Correct 43 ms 3072 KB Output is correct - L* = 40
37 Correct 42 ms 3056 KB Output is correct - L* = 40
38 Correct 43 ms 3072 KB Output is correct - L* = 40
39 Correct 42 ms 3056 KB Output is correct - L* = 40
40 Correct 42 ms 3072 KB Output is correct - L* = 40