답안 #109679

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
109679 2019-05-07T11:28:50 Z popovicirobert Broken Device (JOI17_broken_device) C++14
100 / 100
68 ms 3144 KB
#include "Annalib.h"
#include <bits/stdc++.h>

using namespace std;

void Anna( int N, long long X, int K, int P[] ){

    vector <int> arr(N);

    int i;
    for(i = 0; i < K; i++) {
        arr[P[i]] = 1;
    }

    vector <int> sol(N, 0);

    for(int i = 0; i < N; i += 3) {

        int a = arr[i], b = arr[i + 1], c = arr[i + 2];

        if(a + b + c > 1) {
            continue;
        }

        if(a + b + c == 0) {

            if((X & 3) == 0) {
                sol[i] = 1;
            }
            else if((X & 3) == 2) {
                sol[i] = sol[i + 2] = 1;
            }
            else if((X & 3) == 1) {
                sol[i + 1] = sol[i + 2] = 1;
            }
            else if((X & 3) == 3) {
                sol[i] = sol[i + 1] = sol[i + 2] = 1;
            }
            X >>= 2;

        }
        else {

            if(b == 0) {

                if(X & 1) {

                    if(c == 0) {
                        sol[i + 2] = 1;
                    }
                    else {
                        sol[i] = sol[i + 1] = 1;
                    }

                }
                else {
                    sol[i + 1] = 1;
                }
                X >>= 1;

            }
            else {

                if(X & 1) {
                    sol[i + 2] = 1;
                    X >>= 1;
                }
                else {

                    if((X & 3) == 0) {
                        sol[i] = 1;
                    }
                    else if((X & 3) == 2) {
                        sol[i] = sol[i + 2] = 1;
                    }
                    X >>= 2;
                }

            }

        }

    }

    for(i = 0; i < N; i++) {
        Set(i, sol[i]);
    }

}
#include "Brunolib.h"
#include <bits/stdc++.h>
#define ll long long

using namespace std;

long long Bruno( int N, int A[] ){

    ll ans = 0, pw = 1;

    for(int i = 0; i < N; i += 3) {

        int val = A[i] * 4 + A[i + 1] * 2 + A[i + 2];

        if(val == 0) {
            continue;
        }

        if(val == 2) {
            pw *= 2;
            continue;
        }

        if(val == 1 || val == 6) {
            ans += pw;
            pw *= 2;
            continue;
        }

        if(val == 3) {
            ans += pw;
        }
        if(val == 4) {
            ans += 0;
        }
        if(val == 5) {
            ans += pw * 2;
        }
        if(val == 7) {
            ans += 3 * pw;
        }

        pw *= 4;

    }

    return ans;

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