Submission #26860

#TimeUsernameProblemLanguageResultExecution timeMemory
26860wangyenjenBroken Device (JOI17_broken_device)C++14
100 / 100
68 ms4640 KiB
/// 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;
}
#Verdict Execution timeMemoryGrader output
Fetching results...