Submission #131754

# Submission time Handle Problem Language Result Execution time Memory
131754 2019-07-17T15:02:28 Z zoooma13 Broken Device (JOI17_broken_device) C++14
100 / 100
59 ms 3312 KB
#include "bits/stdc++.h"
#include "Annalib.h"
using namespace std;

pair<int ,int> en(int num){
    if(num == 2) return {1 ,1};
    if(num == 1) return {1 ,0};
    return {0 ,1};
}

void Anna(int N ,long long X ,int K ,int P[]){
    srand(1);
    vector <int> ord(N);
    iota(ord.begin() ,ord.end() ,0);
    random_shuffle(ord.begin() ,ord.end());

    vector <bool> bad(N, 0);
    for(int i=0; i<K; i++)
        bad[P[i]] = true;

    vector <bool> enc(N);
    for(int i=0; i<N; i+=2){
        auto d = en(X%3);
        if((!bad[ord[i]] || !d.first) && (!bad[ord[i+1]] || !d.second)){
            enc[ord[i]] = d.first;
            enc[ord[i+1]] = d.second;
            X /= 3;
        }
    }

    for(int i=0; i<N; i++)
        Set(i ,enc[i]);
}
#include "bits/stdc++.h"
#include "Brunolib.h"
using namespace std;

int de(pair<int ,int> p){
    return p.first+p.second == 2 ? 2 : p.first;
}

long long Bruno(int N ,int A[]){
    srand(1);
    vector <int> ord(N);
    iota(ord.begin() ,ord.end() ,0);
    random_shuffle(ord.begin() ,ord.end());

    long long X = 0LL ,pw = 1LL;
    for(int i=0; i<N; i+=2)
        if(A[ord[i]] || A[ord[i+1]]){
            X += pw*de({A[ord[i]] ,A[ord[i+1]]});
            pw *= 3;
        }

    return X;
}
# Verdict Execution time Memory Grader output
1 Correct 54 ms 3056 KB Output is correct - L* = 40
2 Correct 54 ms 3056 KB Output is correct - L* = 40
3 Correct 54 ms 3056 KB Output is correct - L* = 40
4 Correct 59 ms 3056 KB Output is correct - L* = 40
5 Correct 55 ms 3056 KB Output is correct - L* = 40
6 Correct 55 ms 2856 KB Output is correct - L* = 40
7 Correct 54 ms 3056 KB Output is correct - L* = 40
8 Correct 54 ms 3056 KB Output is correct - L* = 40
9 Correct 54 ms 3056 KB Output is correct - L* = 40
10 Correct 54 ms 3056 KB Output is correct - L* = 40
11 Correct 54 ms 3064 KB Output is correct - L* = 40
12 Correct 54 ms 3064 KB Output is correct - L* = 40
13 Correct 54 ms 3056 KB Output is correct - L* = 40
14 Correct 54 ms 3056 KB Output is correct - L* = 40
15 Correct 54 ms 3056 KB Output is correct - L* = 40
16 Correct 54 ms 3056 KB Output is correct - L* = 40
17 Correct 54 ms 3056 KB Output is correct - L* = 40
18 Correct 54 ms 3312 KB Output is correct - L* = 40
19 Correct 54 ms 3056 KB Output is correct - L* = 40
20 Correct 55 ms 3056 KB Output is correct - L* = 40
21 Correct 54 ms 3056 KB Output is correct - L* = 40
22 Correct 54 ms 3056 KB Output is correct - L* = 40
23 Correct 54 ms 3056 KB Output is correct - L* = 40
24 Correct 55 ms 3056 KB Output is correct - L* = 40
25 Correct 54 ms 3056 KB Output is correct - L* = 40
26 Correct 54 ms 3056 KB Output is correct - L* = 40
27 Correct 54 ms 3056 KB Output is correct - L* = 40
28 Correct 54 ms 3056 KB Output is correct - L* = 40
29 Correct 54 ms 3056 KB Output is correct - L* = 40
30 Correct 54 ms 3056 KB Output is correct - L* = 40
31 Correct 54 ms 3056 KB Output is correct - L* = 40
32 Correct 54 ms 3064 KB Output is correct - L* = 40
33 Correct 55 ms 3056 KB Output is correct - L* = 40
34 Correct 54 ms 3056 KB Output is correct - L* = 40
35 Correct 54 ms 3064 KB Output is correct - L* = 40
36 Correct 55 ms 3176 KB Output is correct - L* = 40
37 Correct 55 ms 3056 KB Output is correct - L* = 40
38 Correct 54 ms 3056 KB Output is correct - L* = 40
39 Correct 54 ms 3056 KB Output is correct - L* = 40
40 Correct 54 ms 3056 KB Output is correct - L* = 40