Submission #26849

# Submission time Handle Problem Language Result Execution time Memory
26849 2017-07-06T10:21:06 Z wangyenjen Broken Device (JOI17_broken_device) C++14
51 / 100
76 ms 4640 KB
/// Author: Wang, Yen-Jen
#include "Annalib.h"
#include <bits/stdc++.h>

using namespace std;

static bool A[60];
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]++;
    }
    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 || cc >= 60) continue;
        if(cnt[i] == 0) {
            if(cc == 59) {
                if(A[cc]) my_set(i , 0 , 1 , 0);
                else my_set(i , 0 , 0 , 1);
                cc++;
            }
            else {
                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 , 1 , 0);
                    else my_set(i , 1 , 0 , 1);
                }
                cc += 2;
            }
        }
        else {
            if(st[i * 3]) {
                if(cc == 59) {
                    if(A[cc]) my_set(i , 0 , 1 , 0);
                    else my_set(i , 0 , 0 , 1);
                    cc++;
                }
                else if(A[cc] && !A[cc + 1]) {
                    my_set(i , 0 , 1 , 1);
                    cc += 2;
                }
            }
            else if(st[i * 3 + 1]) {
                if(cc == 59) {
                    if(!A[cc]) {
                        my_set(i , 0 , 0 , 1);
                        cc++;
                    }
                }
                else {
                    if(!A[cc] && !A[cc + 1]) {
                        my_set(i , 1 , 0 , 1);
                        cc += 2;
                    }
                }
            }
            else {
                if(cc == 59) {
                    if(A[cc]) {
                        my_set(i , 0 , 1 , 0);
                        cc++;
                    }
                }
                else {
                    if(!A[cc] && A[cc + 1]) {
                        my_set(i , 1 , 1 , 0);
                        cc += 2;
                    }
                }
            }
        }
    }
    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++] = 0 , B[cc++] = 1;
            }
            else {
                if(A[i * 3 + 2]) B[cc++] = 0 , B[cc++] = 0;
                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++] = 1;
            }
            else {
                if(A[i * 3 + 2]) B[cc++] = 0;
            }
        }
    }
    for(int i = 0; i < 60; i++) X |= ((long long)B[i]<<i);
    return X;
}
# Verdict Execution time Memory Grader output
1 Partially correct 35 ms 4640 KB Output is partially correct - L* = 20
2 Partially correct 38 ms 4640 KB Output is partially correct - L* = 20
3 Partially correct 41 ms 4640 KB Output is partially correct - L* = 20
4 Partially correct 39 ms 4640 KB Output is partially correct - L* = 21
5 Partially correct 39 ms 4640 KB Output is partially correct - L* = 20
6 Partially correct 41 ms 4640 KB Output is partially correct - L* = 20
7 Partially correct 39 ms 4640 KB Output is partially correct - L* = 20
8 Partially correct 58 ms 4640 KB Output is partially correct - L* = 20
9 Partially correct 35 ms 4640 KB Output is partially correct - L* = 21
10 Partially correct 52 ms 4640 KB Output is partially correct - L* = 20
11 Partially correct 45 ms 4640 KB Output is partially correct - L* = 20
12 Partially correct 45 ms 4640 KB Output is partially correct - L* = 20
13 Partially correct 45 ms 4640 KB Output is partially correct - L* = 21
14 Partially correct 45 ms 4640 KB Output is partially correct - L* = 20
15 Partially correct 41 ms 4640 KB Output is partially correct - L* = 20
16 Partially correct 45 ms 4640 KB Output is partially correct - L* = 21
17 Partially correct 38 ms 4640 KB Output is partially correct - L* = 20
18 Partially correct 41 ms 4640 KB Output is partially correct - L* = 20
19 Partially correct 41 ms 4640 KB Output is partially correct - L* = 20
20 Partially correct 41 ms 4640 KB Output is partially correct - L* = 20
21 Partially correct 39 ms 4640 KB Output is partially correct - L* = 20
22 Partially correct 45 ms 4640 KB Output is partially correct - L* = 20
23 Partially correct 41 ms 4640 KB Output is partially correct - L* = 20
24 Partially correct 42 ms 4640 KB Output is partially correct - L* = 21
25 Partially correct 35 ms 4640 KB Output is partially correct - L* = 20
26 Partially correct 35 ms 4640 KB Output is partially correct - L* = 20
27 Partially correct 58 ms 4640 KB Output is partially correct - L* = 22
28 Partially correct 36 ms 4640 KB Output is partially correct - L* = 21
29 Partially correct 32 ms 4640 KB Output is partially correct - L* = 20
30 Partially correct 45 ms 4640 KB Output is partially correct - L* = 21
31 Partially correct 28 ms 4640 KB Output is partially correct - L* = 20
32 Partially correct 62 ms 4640 KB Output is partially correct - L* = 20
33 Partially correct 35 ms 4640 KB Output is partially correct - L* = 20
34 Partially correct 76 ms 4640 KB Output is partially correct - L* = 22
35 Partially correct 49 ms 4640 KB Output is partially correct - L* = 20
36 Partially correct 41 ms 4640 KB Output is partially correct - L* = 20
37 Partially correct 35 ms 4640 KB Output is partially correct - L* = 20
38 Partially correct 35 ms 4640 KB Output is partially correct - L* = 20
39 Partially correct 32 ms 4640 KB Output is partially correct - L* = 20
40 Partially correct 35 ms 4640 KB Output is partially correct - L* = 20