QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#730011#9575. $P \oplus Q = R$ucup-team5799WA 19ms3808kbC++201.6kb2024-11-09 18:17:442024-11-09 18:17:46

Judging History

你现在查看的是最新测评结果

  • [2024-11-10 08:23:38]
  • hack成功,自动添加数据
  • (/hack/1156)
  • [2024-11-09 18:17:46]
  • 评测
  • 测评结果:WA
  • 用时:19ms
  • 内存:3808kb
  • [2024-11-09 18:17:44]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

void printArr(vector<int> ans) {
    for (int x : ans) {
        cout << x << " ";
    }
    cout << '\n';
}

void solve() {
    int n; cin >> n;
    if (n == 1) {
        cout << "Yes" << '\n';
        cout << 0 << '\n';
        cout << 0 << '\n';
        return;
    }
    int k = log2(n);
    if ((1 << k) != n) {
        cout << "No" << '\n';
        return;
    }
    vector<int> id(n);
    iota(id.begin(), id.end(), 0);
    auto check = [&](vector<int> a)  {
        sort(a.begin(), a.end());
        for (int i = 0;i < n;i++) {
            if (a[i] != id[i]) return false;
        }
        return true;
    };
    vector<int> b(n);
    for (int p = 0;p < n;p++) {
        int i = p, j = 0;
        do {
            b[i] = j;
            i = (i + 2) % n;
            j++;
        } while (i != p);
        for (int q = (p & 1) ^ 1;q < n;q += 2) {
            int ii = q, jj = n / 2;
            do {
                b[ii] = jj;
                jj++;
                ii = (ii - 2 + n) % n;
            } while (ii != q);

            vector<int> ans(n);
            for (int i = 0;i < n;i++) {
                ans[i] = id[i] ^ b[i];
            }
            // printArr(b);
            if (check(ans)) {
                cout << "Yes" << '\n';
                printArr(id);
                printArr(ans);
                return;
            }
        }
    }
    cout << "No" << '\n';
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t; cin >> t;
    while(t--) solve();
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3628kb

input:

2
3
4

output:

No
Yes
0 1 2 3 
0 2 3 1 

result:

ok Correct. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 19ms
memory: 3808kb

input:

1999
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101...

output:

Yes
0
0
No
No
Yes
0 1 2 3 
0 2 3 1 
No
No
No
Yes
0 1 2 3 4 5 6 7 
0 4 3 7 6 2 5 1 
No
No
No
No
No
No
No
Yes
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
0 14 3 13 6 8 5 11 12 2 15 1 10 4 9 7 
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ...

result:

wrong answer Testcase 12, n = 12, Jury has better solution. (test case 12)