Submission #754119

# Submission time Handle Problem Language Result Execution time Memory
754119 2023-06-06T18:03:49 Z piOOE Broken Device (JOI17_broken_device) C++17
100 / 100
39 ms 2440 KB
#include "Annalib.h"

void Anna(int N, long long x, int K, int P[]) {
    int used[150]{};

    for (int i = 0; i < K; ++i) {
        used[P[i]] = true;
    }

    for (int i = N - 3; i >= 0; i -= 3) {
        int a = 0, b = 0, c = 0;

        if (used[i] + used[i + 1] + used[i + 2] == 0) {
            if (x % 4 == 0) {
                b = 1;
            } else if (x % 4 == 1) {
                a = c = 1;
            } else if (x % 4 == 2) {
                a = b = 1;
            } else {
                a = b = c = 1;
            }
            x /= 4;
        } else if (used[i] + used[i + 1] + used[i + 2] == 1) {
            if (x % 2 == 0) {
                if (!used[i + 2]) {
                    c = 1;
                } else {
                    a = bool(x % 4), b = 1;
                    x /= 2;
                }
            } else if (used[i]) {
                b = c = 1;
            } else {
                a = 1;
            }
            x /= 2;
        }

        Set(i, a), Set(i + 1, b), Set(i + 2, c);
    }
}
#include "Brunolib.h"

long long Bruno(int N, int A[]) {
    long long x = 0;

    for (int i = 0; i < N; i += 3) {
        int d = A[i] * 4 + A[i + 1] * 2 + A[i + 2];
        if (d == 1) {
            x = x * 2;
        } else if (d == 2) {
            x = x * 4;
        } else if (d == 3 || d == 4) {
            x = x * 2 + 1;
        } else if (d == 5) {
            x = x * 4 + 1;
        } else if (d == 6) {
            x = x * 4 + 2;
        } else if (d == 7) {
            x = x * 4 + 3;
        }
    }

    return x;
}
# Verdict Execution time Memory Grader output
1 Correct 33 ms 2296 KB Output is correct - L* = 40
2 Correct 39 ms 2196 KB Output is correct - L* = 40
3 Correct 28 ms 2312 KB Output is correct - L* = 40
4 Correct 28 ms 2244 KB Output is correct - L* = 40
5 Correct 28 ms 2236 KB Output is correct - L* = 40
6 Correct 29 ms 2312 KB Output is correct - L* = 40
7 Correct 30 ms 2300 KB Output is correct - L* = 40
8 Correct 29 ms 2292 KB Output is correct - L* = 40
9 Correct 30 ms 2372 KB Output is correct - L* = 40
10 Correct 28 ms 2224 KB Output is correct - L* = 40
11 Correct 36 ms 2332 KB Output is correct - L* = 40
12 Correct 37 ms 2212 KB Output is correct - L* = 40
13 Correct 28 ms 2216 KB Output is correct - L* = 40
14 Correct 28 ms 2240 KB Output is correct - L* = 40
15 Correct 26 ms 2308 KB Output is correct - L* = 40
16 Correct 26 ms 2288 KB Output is correct - L* = 40
17 Correct 28 ms 2372 KB Output is correct - L* = 40
18 Correct 28 ms 2228 KB Output is correct - L* = 40
19 Correct 33 ms 2284 KB Output is correct - L* = 40
20 Correct 30 ms 2252 KB Output is correct - L* = 40
21 Correct 26 ms 2372 KB Output is correct - L* = 40
22 Correct 25 ms 2228 KB Output is correct - L* = 40
23 Correct 27 ms 2332 KB Output is correct - L* = 40
24 Correct 29 ms 2232 KB Output is correct - L* = 40
25 Correct 26 ms 2312 KB Output is correct - L* = 40
26 Correct 32 ms 2244 KB Output is correct - L* = 40
27 Correct 35 ms 2328 KB Output is correct - L* = 40
28 Correct 32 ms 2304 KB Output is correct - L* = 40
29 Correct 33 ms 2440 KB Output is correct - L* = 40
30 Correct 29 ms 2244 KB Output is correct - L* = 40
31 Correct 28 ms 2316 KB Output is correct - L* = 40
32 Correct 26 ms 2280 KB Output is correct - L* = 40
33 Correct 39 ms 2328 KB Output is correct - L* = 40
34 Correct 38 ms 2240 KB Output is correct - L* = 40
35 Correct 28 ms 2236 KB Output is correct - L* = 40
36 Correct 28 ms 2232 KB Output is correct - L* = 40
37 Correct 32 ms 2144 KB Output is correct - L* = 40
38 Correct 30 ms 2316 KB Output is correct - L* = 40
39 Correct 33 ms 2252 KB Output is correct - L* = 40
40 Correct 30 ms 2244 KB Output is correct - L* = 40