QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#758264#9575. $P \oplus Q = R$arnold518#WA 1ms3876kbC++171.3kb2024-11-17 17:16:202024-11-17 17:16:20

Judging History

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

  • [2024-11-17 17:16:20]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3876kb
  • [2024-11-17 17:16:20]
  • 提交

answer

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

typedef long long ll;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int N = 200005;

const int a4[4] = {0, 2, 1, 3};
const int b4[4] = {3, 2, 0, 1};

const int a8[8] = {0, 1, 2, 3, 4, 5, 6, 7};
const int b8[8] = {0, 2, 4, 6, 3, 1, 7, 5};

int a[N], b[N];

void construct(int X, int I) {
    if (X == 4) {
        for (int i=0;i<4;i++) {
            a[I+i] = a4[i];
            b[I+i] = b4[i];
        }
        return;
    }
    if (X == 8) {
        for (int i=0;i<8;i++) {
            a[I+i] = a8[i];
            b[I+i] = b8[i];
        }
        return;
    }
    int chunk = X/4;
    for (int i=0;i<4;i++) {
        construct(chunk, i*chunk);
        for (int j=i*chunk;j<(i+1)*chunk;j++) {
            a[j] = 4 * a[j] + a4[i];
            b[j] = 4 * b[j] + b4[i];
        }
    }
}

void solve() {
    int n;
    scanf("%d",&n);
    if(n <= 2 || ((n & (-n)) != n)) {
        puts("No");
        return;
    }
    puts("Yes");
    construct(n, 0);
    for (int i=0;i<n;i++) {
        printf("%d ", a[i]);
    }
    puts("");
    for (int i=0;i<n;i++) {
        printf("%d ", b[i]);
    }
    puts("");
}

int main()
{
    // ios_base::sync_with_stdio(false); cin.tie(NULL);
    int tc;
    scanf("%d",&tc);
    while(tc--) {
        solve();
    }
}

詳細信息

Test #1:

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

input:

2
3
4

output:

No
Yes
0 2 1 3 
3 2 0 1 

result:

ok Correct. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3768kb

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:

No
No
No
Yes
0 2 1 3 
3 2 0 1 
No
No
No
Yes
0 1 2 3 4 5 6 7 
0 2 4 6 3 1 7 5 
No
No
No
No
No
No
No
Yes
0 8 4 12 2 10 6 14 1 9 5 13 3 11 7 15 
15 11 3 7 14 10 2 6 12 8 0 4 13 9 1 5 
No
No
No
No
No
No
No
No
No
No
No
No
No
No
No
Yes
0 4 8 12 16 20 24 28 2 6 10 14 18 22 26 30 1 5 9 13 17 21 25 29 3 7 11...

result:

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