답안 #986692

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
986692 2024-05-21T04:01:42 Z PurpleCrayon Ancient Machine 2 (JOI23_ancient2) C++17
97 / 100
71 ms 1100 KB
#include "ancient2.h"
#include <bits/stdc++.h>
using namespace std;

#define sz(v) int(v.size())
#define ar array
typedef long long ll;

mt19937 rng(69);

int rnd(int l, int r) {
	return uniform_int_distribution<int>(l, r)(rng);
}

int qry(vector<int> v) {
    int m = 2 * sz(v);
    vector<int> a(m), b(m);
    for (int i = 0; i < m; i++) {
        int par = i % 2, c = i / 2;
        a[i] = ((c + 1) % sz(v)) * 2 + par;
        if (v[c]) {
            b[i] = ((c + 1) % sz(v)) * 2 + (par ^ 1);
        } else {
            b[i] = a[i];
        }
    }

    return Query(m, a, b) % 2;
}

string Solve(int N) {
    const int p = 57;
    const int n = 1e3;
    assert(n == N);

    bitset<n> b[n]; // basis
    int who[n];
    for (int i = 0; i < n; i++) b[i] = 0;

    int cnt = 0;
    while (cnt < n) {
        int x = rnd(1, p);
        vector<int> use(x);
        for (int i = 0; i < x; i++) use[i] = rnd(0, 1);

        bitset<n> cur;
        int my_who = 0;
        for (int i = 0; i < n; i++) cur[i] = use[i % x];

        for (int i = 0; i < n; i++) if (cur[i]) {
            if (b[i].any()) {
                cur ^= b[i];
                my_who ^= who[i];
            } else {
                b[i] = cur;
                who[i] = my_who ^= qry(use);
                cnt++;
                break;
            }
        }
    }

    string s;
    for (int i = 0; i < n; i++) {
        int ans = 0;

        bitset<n> cur; cur[i] = 1;
        for (int j = 0; j < n; j++) if (cur[j]) {
            cur ^= b[j];
            ans ^= who[j];
        }

        s += char('0' + ans);
    }

    return s;
}
# 결과 실행 시간 메모리 Grader output
1 Partially correct 62 ms 592 KB Output is partially correct
2 Partially correct 62 ms 596 KB Output is partially correct
3 Partially correct 63 ms 836 KB Output is partially correct
4 Partially correct 61 ms 756 KB Output is partially correct
5 Partially correct 69 ms 836 KB Output is partially correct
6 Partially correct 62 ms 592 KB Output is partially correct
7 Partially correct 64 ms 592 KB Output is partially correct
8 Partially correct 64 ms 820 KB Output is partially correct
9 Partially correct 66 ms 592 KB Output is partially correct
10 Partially correct 61 ms 840 KB Output is partially correct
11 Partially correct 65 ms 588 KB Output is partially correct
12 Partially correct 62 ms 588 KB Output is partially correct
13 Partially correct 63 ms 596 KB Output is partially correct
14 Partially correct 69 ms 848 KB Output is partially correct
15 Partially correct 62 ms 836 KB Output is partially correct
16 Partially correct 62 ms 588 KB Output is partially correct
17 Partially correct 62 ms 592 KB Output is partially correct
18 Partially correct 65 ms 588 KB Output is partially correct
19 Partially correct 63 ms 592 KB Output is partially correct
20 Partially correct 63 ms 844 KB Output is partially correct
21 Partially correct 63 ms 592 KB Output is partially correct
22 Partially correct 62 ms 836 KB Output is partially correct
23 Partially correct 71 ms 592 KB Output is partially correct
24 Partially correct 68 ms 860 KB Output is partially correct
25 Partially correct 64 ms 832 KB Output is partially correct
26 Partially correct 62 ms 824 KB Output is partially correct
27 Partially correct 64 ms 588 KB Output is partially correct
28 Partially correct 64 ms 620 KB Output is partially correct
29 Partially correct 64 ms 592 KB Output is partially correct
30 Partially correct 62 ms 596 KB Output is partially correct
31 Partially correct 63 ms 844 KB Output is partially correct
32 Partially correct 63 ms 840 KB Output is partially correct
33 Partially correct 63 ms 592 KB Output is partially correct
34 Partially correct 62 ms 592 KB Output is partially correct
35 Partially correct 62 ms 596 KB Output is partially correct
36 Partially correct 63 ms 592 KB Output is partially correct
37 Partially correct 62 ms 588 KB Output is partially correct
38 Partially correct 64 ms 592 KB Output is partially correct
39 Partially correct 64 ms 840 KB Output is partially correct
40 Partially correct 63 ms 824 KB Output is partially correct
41 Partially correct 61 ms 592 KB Output is partially correct
42 Partially correct 63 ms 840 KB Output is partially correct
43 Partially correct 62 ms 588 KB Output is partially correct
44 Partially correct 64 ms 844 KB Output is partially correct
45 Partially correct 62 ms 820 KB Output is partially correct
46 Partially correct 63 ms 588 KB Output is partially correct
47 Partially correct 62 ms 848 KB Output is partially correct
48 Partially correct 63 ms 588 KB Output is partially correct
49 Partially correct 62 ms 624 KB Output is partially correct
50 Partially correct 65 ms 588 KB Output is partially correct
51 Partially correct 63 ms 836 KB Output is partially correct
52 Partially correct 63 ms 820 KB Output is partially correct
53 Partially correct 62 ms 840 KB Output is partially correct
54 Partially correct 63 ms 840 KB Output is partially correct
55 Partially correct 62 ms 592 KB Output is partially correct
56 Partially correct 64 ms 872 KB Output is partially correct
57 Partially correct 61 ms 584 KB Output is partially correct
58 Partially correct 61 ms 588 KB Output is partially correct
59 Partially correct 64 ms 1100 KB Output is partially correct
60 Partially correct 63 ms 588 KB Output is partially correct
61 Partially correct 62 ms 596 KB Output is partially correct
62 Partially correct 63 ms 596 KB Output is partially correct
63 Partially correct 66 ms 844 KB Output is partially correct