답안 #26860

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
26860 2017-07-06T11:00:02 Z wangyenjen Broken Device (JOI17_broken_device) C++14
100 / 100
68 ms 4640 KB
/// Author: Wang, Yen-Jen
#include "Annalib.h"
#include <bits/stdc++.h>

using namespace std;

static bool A[150];
static bool B[150];
static int cnt[50];
static bool st[150];

inline static void my_set(int p , int a , int b , int c) {
    B[p * 3] = a;
    B[p * 3 + 1] = b;
    B[p * 3 + 2] = c;
}

void Anna(int N , long long X , int K , int P[]) {
    memset(st , 0 , sizeof(st));
    memset(cnt , 0 , sizeof(cnt));
    for(int i = 0; i < K; i++) {
        st[P[i]] = 1;
        cnt[P[i] / 3]++;
    }
    memset(A , 0 , sizeof(A));
    for(int i = 0; i < 60; i++) {
        A[i] = (X&1);
        X >>= 1;
    }
    int cc = 0;
    memset(B , 0 , sizeof(B));
    for(int i = 0; i < N / 3; i++) {
        if(cnt[i] >= 2) continue;
        if(cnt[i] == 0) {
            if(A[cc]) {
                if(A[cc + 1]) my_set(i , 1 , 1 , 1);
                else my_set(i , 0 , 1 , 1);
            }
            else {
                if(A[cc + 1]) my_set(i , 1 , 0 , 1);
                else my_set(i , 1 , 0 , 0);
            }
            cc += 2;
        }
        else {
            if(st[i * 3]) {
                if(A[cc]) my_set(i , 0 , 0 , 1);
                else my_set(i , 0 , 1 , 0);
                cc++;
            }
            else if(st[i * 3 + 1]) {
                if(A[cc]) {
                    my_set(i , 0 , 0 , 1);
                    cc++;
                }
                else if(!A[cc + 1]) {
                    my_set(i , 1 , 0 , 0);
                    cc += 2;
                }
                else {
                    my_set(i , 1 , 0 , 1);
                    cc += 2;
                }
            }
            else {
                if(A[cc]) {
                    my_set(i , 1 , 1 , 0);
                    cc++;
                }
                else {
                    my_set(i , 0 , 1 , 0);
                    cc++;
                }
            }
        }
    }
    for(int i = 0; i < N; i++) Set(i , B[i]);
}
/// Author: Wang, Yen-Jen
#include "Brunolib.h"
#include <bits/stdc++.h>

using namespace std;

static int B[150];

long long Bruno(int N , int A[]) {
    long long X = 0;
    int cc = 0;
    for(int i = 0; i < N / 3; i++) {
        if(!(A[i * 3] || A[i * 3 + 1] || A[i * 3 + 2])) continue;
        if(A[i * 3]) {
            if(A[i * 3 + 1]) {
                if(A[i * 3 + 2]) B[cc++] = 1 , B[cc++] = 1;
                else B[cc++] = 1;
            }
            else {
                if(A[i * 3 + 2]) B[cc++] = 0 , B[cc++] = 1;
                else B[cc++] = 0 , B[cc++] = 0;
            }
        }
        else {
            if(A[i * 3 + 1]) {
                if(A[i * 3 + 2]) B[cc++] = 1 , B[cc++] = 0;
                else B[cc++] = 0;
            }
            else if(A[i * 3 + 2]) B[cc++] = 1;
        }
    }
    for(int i = 0; i < 60; i++) X |= ((long long)B[i]<<i);
    return X;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 4640 KB Output is correct - L* = 40
2 Correct 32 ms 4640 KB Output is correct - L* = 40
3 Correct 35 ms 4640 KB Output is correct - L* = 40
4 Correct 35 ms 4640 KB Output is correct - L* = 40
5 Correct 35 ms 4640 KB Output is correct - L* = 40
6 Correct 35 ms 4640 KB Output is correct - L* = 40
7 Correct 35 ms 4640 KB Output is correct - L* = 40
8 Correct 32 ms 4640 KB Output is correct - L* = 40
9 Correct 39 ms 4640 KB Output is correct - L* = 40
10 Correct 41 ms 4640 KB Output is correct - L* = 40
11 Correct 35 ms 4640 KB Output is correct - L* = 40
12 Correct 39 ms 4640 KB Output is correct - L* = 40
13 Correct 52 ms 4640 KB Output is correct - L* = 40
14 Correct 46 ms 4640 KB Output is correct - L* = 40
15 Correct 48 ms 4640 KB Output is correct - L* = 40
16 Correct 39 ms 4640 KB Output is correct - L* = 40
17 Correct 41 ms 4640 KB Output is correct - L* = 40
18 Correct 48 ms 4640 KB Output is correct - L* = 40
19 Correct 45 ms 4640 KB Output is correct - L* = 40
20 Correct 41 ms 4640 KB Output is correct - L* = 40
21 Correct 62 ms 4640 KB Output is correct - L* = 40
22 Correct 48 ms 4640 KB Output is correct - L* = 40
23 Correct 46 ms 4640 KB Output is correct - L* = 40
24 Correct 45 ms 4640 KB Output is correct - L* = 40
25 Correct 62 ms 4640 KB Output is correct - L* = 40
26 Correct 39 ms 4640 KB Output is correct - L* = 40
27 Correct 32 ms 4640 KB Output is correct - L* = 40
28 Correct 41 ms 4640 KB Output is correct - L* = 40
29 Correct 62 ms 4640 KB Output is correct - L* = 40
30 Correct 62 ms 4640 KB Output is correct - L* = 40
31 Correct 41 ms 4640 KB Output is correct - L* = 40
32 Correct 49 ms 4640 KB Output is correct - L* = 40
33 Correct 45 ms 4640 KB Output is correct - L* = 40
34 Correct 41 ms 4640 KB Output is correct - L* = 40
35 Correct 52 ms 4640 KB Output is correct - L* = 40
36 Correct 68 ms 4640 KB Output is correct - L* = 40
37 Correct 41 ms 4640 KB Output is correct - L* = 40
38 Correct 49 ms 4640 KB Output is correct - L* = 40
39 Correct 52 ms 4640 KB Output is correct - L* = 40
40 Correct 52 ms 4640 KB Output is correct - L* = 40