Submission #994409

# Submission time Handle Problem Language Result Execution time Memory
994409 2024-06-07T14:36:20 Z Sharky Broken Device (JOI17_broken_device) C++17
100 / 100
36 ms 3024 KB
#include "Annalib.h"
#include <bits/stdc++.h>
using namespace std;

namespace anna {
const long long purple = 694202512019219198LL;
const int amogus = 696969;

mt19937 rng(amogus);
vector<int> p(151), inv(151);

int rnd(int u, int v) {
    return uniform_int_distribution<int> (u, v) (rng);
}

void gen_perm() {
    for (int i = 0; i < 150; i++) p[i] = i;
    for (int i = 0; i < 150; i++) swap(p[rnd(0, 149)], p[rnd(0, 149)]);
    for (int i = 0; i < 150; i++) inv[p[i]] = i;
}
}

using namespace anna;

void Anna(int N, long long _X, int K, int _P[]){
    gen_perm();
    long long X = _X;
    X ^= purple;
    vector<int> P, seq(N);
    set<int> broken;
    for (int i = 0; i < K; i++) {
        P.push_back(p[_P[i]]);
        broken.insert(P.back());
    }
    for (int i = 0; i < N; i += 2) {
        if (X == 0) seq[i] = seq[i + 1] = 0;
        else {
            int b = X % 3;
            X /= 3;
            if (b == 0 && !broken.count(i + 1)) seq[i] = 0, seq[i + 1] = 1;
            else if (b == 1 && !broken.count(i)) seq[i] = 1, seq[i + 1] = 0;
            else if (b == 2 && !broken.count(i) && !broken.count(i + 1)) seq[i] = 1, seq[i + 1] = 1;
            else {
                X *= 3; X += b;
                seq[i] = seq[i + 1] = 0;
            }
        }
    }
    for (int i = 0; i < N; i++) Set(inv[i], seq[i]);
}
#include "Brunolib.h"
#include <bits/stdc++.h>
using namespace std;

namespace bruno {
const long long purple = 694202512019219198LL;
const int amogus = 696969;

mt19937 rng(amogus);
vector<int> p(151), inv(151);

int rnd(int u, int v) {
    return uniform_int_distribution<int> (u, v) (rng);
}

void gen_perm() {
    for (int i = 0; i < 150; i++) p[i] = i;
    for (int i = 0; i < 150; i++) swap(p[rnd(0, 149)], p[rnd(0, 149)]);
    for (int i = 0; i < 150; i++) inv[p[i]] = i;
}
}

using namespace bruno;

// 0: 1
// 1: 2
// 01: 3
// 11: 4

long long Bruno(int N, int A[]) {
    gen_perm();
    long long X = 0;
    vector<int> a(N);
    for (int i = 0; i < N; i++) a[i] = A[inv[i]];
    for (int i = N - 2; i >= 0; i -= 2) {
        int b1 = a[i], b2 = a[i + 1];
        if (b1 || b2) X *= 3;
        if (b1 == 0 && b2 == 1) X += 0;
        else if (b1 == 1 && b2 == 0) X += 1;
        else if (b1 == 1 && b2 == 1) X += 2;
    }
    X ^= purple;
    return X;
}
# Verdict Execution time Memory Grader output
1 Correct 30 ms 2784 KB Output is correct - L* = 40
2 Correct 30 ms 2776 KB Output is correct - L* = 40
3 Correct 32 ms 2748 KB Output is correct - L* = 40
4 Correct 31 ms 2780 KB Output is correct - L* = 40
5 Correct 31 ms 2688 KB Output is correct - L* = 40
6 Correct 31 ms 2788 KB Output is correct - L* = 40
7 Correct 31 ms 2808 KB Output is correct - L* = 40
8 Correct 34 ms 2776 KB Output is correct - L* = 40
9 Correct 31 ms 2940 KB Output is correct - L* = 40
10 Correct 32 ms 2788 KB Output is correct - L* = 40
11 Correct 32 ms 2740 KB Output is correct - L* = 40
12 Correct 30 ms 2752 KB Output is correct - L* = 40
13 Correct 30 ms 2776 KB Output is correct - L* = 40
14 Correct 30 ms 2772 KB Output is correct - L* = 40
15 Correct 30 ms 2748 KB Output is correct - L* = 40
16 Correct 31 ms 2752 KB Output is correct - L* = 40
17 Correct 32 ms 2780 KB Output is correct - L* = 40
18 Correct 31 ms 2748 KB Output is correct - L* = 40
19 Correct 35 ms 2776 KB Output is correct - L* = 40
20 Correct 35 ms 2784 KB Output is correct - L* = 40
21 Correct 31 ms 2772 KB Output is correct - L* = 40
22 Correct 32 ms 2768 KB Output is correct - L* = 40
23 Correct 30 ms 3024 KB Output is correct - L* = 40
24 Correct 31 ms 2776 KB Output is correct - L* = 40
25 Correct 33 ms 2748 KB Output is correct - L* = 40
26 Correct 31 ms 2760 KB Output is correct - L* = 40
27 Correct 33 ms 2752 KB Output is correct - L* = 40
28 Correct 33 ms 2772 KB Output is correct - L* = 40
29 Correct 31 ms 2780 KB Output is correct - L* = 40
30 Correct 32 ms 2776 KB Output is correct - L* = 40
31 Correct 32 ms 2772 KB Output is correct - L* = 40
32 Correct 33 ms 2768 KB Output is correct - L* = 40
33 Correct 33 ms 2800 KB Output is correct - L* = 40
34 Correct 35 ms 2780 KB Output is correct - L* = 40
35 Correct 36 ms 2752 KB Output is correct - L* = 40
36 Correct 31 ms 2752 KB Output is correct - L* = 40
37 Correct 34 ms 2740 KB Output is correct - L* = 40
38 Correct 31 ms 2780 KB Output is correct - L* = 40
39 Correct 31 ms 2768 KB Output is correct - L* = 40
40 Correct 28 ms 2372 KB Output is correct - L* = 40