Submission #923184

# Submission time Handle Problem Language Result Execution time Memory
923184 2024-02-06T19:59:02 Z gawr_gura Broken Device (JOI17_broken_device) C++17
100 / 100
28 ms 2740 KB
#include <bits/stdc++.h>

#include "Annalib.h"
using namespace std;

void Anna(int N, long long X, int K, int P[]) {
        vector<int> a(N);
        vector<int> wrong(N);
        for (int i = 0; i < K; i++) wrong[P[i]] = 1;
        for (int i = 0; i < N; i += 3) {
                int z = X % 4;
                if (wrong[i] + wrong[i + 1] + wrong[i + 2] == 0) {
                        X /= 4;
                        // cout << "? " << i << '\n';
                        if (z == 1) {
                                a[i + 2] = a[i + 1] = 1;
                        } else {
                                a[i] = 1;
                                a[i + 1] = z & 1;
                                a[i + 2] = z / 2;
                        }
                } else if (wrong[i] + wrong[i + 1] + wrong[i + 2] == 1) {
                        if (wrong[i]) {
                                if (z == 1) {
                                        a[i + 1] = a[i + 2] = 1;
                                        X /= 4;
                                } else {
                                        a[i + 1 + (z & 1)] = 1;
                                        X /= 2;
                                }
                        } else if (wrong[i + 1]) {
                                if (z % 2 == 0) {
                                        a[i] = 1;
                                        a[i + 2] = z / 2;
                                        X /= 4;
                                } else {
                                        a[i + 2] = 1;
                                        X /= 2;
                                }
                        } else {
                                if (z == 0) {
                                        a[i] = 1;
                                        X /= 4;
                                } else {
                                        a[i + 1] = 1;
                                        a[i] = z & 1;
                                        X /= 2;
                                }
                        }
                }
        }
        for (int i = 0; i < N; i++) Set(i, a[i]);
}
#include <bits/stdc++.h>

#include "Brunolib.h"
using namespace std;

long long Bruno(int N, int A[]) {
        int64_t X = 0;
        for (int i = N - 3; i >= 0; i -= 3) {
                if (A[i] + A[i + 1] + A[i + 2] == 0) continue;
                if (A[i] == 1) {
                        if (A[i + 1] == 1 && A[i + 2] == 0) {
                                X = X * 2 + 1;
                        } else {
                                X = (X * 2 + A[i + 2]) * 2 + A[i + 1];
                        }
                } else {
                        if (A[i + 1] + A[i + 2] == 1) {
                                X = X * 2 + A[i + 2];
                        } else {
                                X = X * 4 + 1;
                        }
                }
        }
        return X;
}
# Verdict Execution time Memory Grader output
1 Correct 26 ms 2396 KB Output is correct - L* = 40
2 Correct 25 ms 2304 KB Output is correct - L* = 40
3 Correct 27 ms 2584 KB Output is correct - L* = 40
4 Correct 25 ms 2396 KB Output is correct - L* = 40
5 Correct 25 ms 2396 KB Output is correct - L* = 40
6 Correct 25 ms 2372 KB Output is correct - L* = 40
7 Correct 25 ms 2396 KB Output is correct - L* = 40
8 Correct 24 ms 2740 KB Output is correct - L* = 40
9 Correct 25 ms 2396 KB Output is correct - L* = 40
10 Correct 24 ms 2408 KB Output is correct - L* = 40
11 Correct 25 ms 2484 KB Output is correct - L* = 40
12 Correct 25 ms 2624 KB Output is correct - L* = 40
13 Correct 25 ms 2372 KB Output is correct - L* = 40
14 Correct 25 ms 2396 KB Output is correct - L* = 40
15 Correct 28 ms 2520 KB Output is correct - L* = 40
16 Correct 25 ms 2304 KB Output is correct - L* = 40
17 Correct 25 ms 2396 KB Output is correct - L* = 40
18 Correct 25 ms 2496 KB Output is correct - L* = 40
19 Correct 25 ms 2380 KB Output is correct - L* = 40
20 Correct 26 ms 2556 KB Output is correct - L* = 40
21 Correct 25 ms 2392 KB Output is correct - L* = 40
22 Correct 25 ms 2396 KB Output is correct - L* = 40
23 Correct 25 ms 2396 KB Output is correct - L* = 40
24 Correct 25 ms 2404 KB Output is correct - L* = 40
25 Correct 25 ms 2508 KB Output is correct - L* = 40
26 Correct 25 ms 2396 KB Output is correct - L* = 40
27 Correct 25 ms 2392 KB Output is correct - L* = 40
28 Correct 25 ms 2396 KB Output is correct - L* = 40
29 Correct 25 ms 2396 KB Output is correct - L* = 40
30 Correct 25 ms 2396 KB Output is correct - L* = 40
31 Correct 25 ms 2396 KB Output is correct - L* = 40
32 Correct 25 ms 2396 KB Output is correct - L* = 40
33 Correct 27 ms 2644 KB Output is correct - L* = 40
34 Correct 25 ms 2396 KB Output is correct - L* = 40
35 Correct 25 ms 2396 KB Output is correct - L* = 40
36 Correct 26 ms 2480 KB Output is correct - L* = 40
37 Correct 25 ms 2308 KB Output is correct - L* = 40
38 Correct 25 ms 2460 KB Output is correct - L* = 40
39 Correct 25 ms 2480 KB Output is correct - L* = 40
40 Correct 27 ms 2396 KB Output is correct - L* = 40