QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#736978#9575. $P \oplus Q = R$A_programmerAC ✓172ms5736kbC++171.9kb2024-11-12 14:08:342024-11-12 14:08:35

Judging History

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

  • [2024-11-12 14:08:35]
  • 评测
  • 测评结果:AC
  • 用时:172ms
  • 内存:5736kb
  • [2024-11-12 14:08:34]
  • 提交

answer

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

const int maxn = 2e5 + 5;

void D(int n, int k, int *p1, int *p2)
{
    if (!n) return p1[0] = p2[0] = 0, void();
    if (n == 1) return p1[0] = p2[1] = 0, p1[1] = p2[0] = 1, void();

    int mid = 1 << (n - 1);
    if (k < mid) D(n - 1, k, p1, p1 + mid);
    else D(n - 1, k - mid, p1 + mid, p1);
    for (int i = 0; i < (1 << n); i++) p2[i] = p1[(1 << n) - 1 - i];
    for (int i = mid; i < (1 << n); i++) p1[i] += mid;
    for (int i = 0; i < mid; i++) p2[i] += mid;
}

void C(int x, int *p1, int *p2)
{
    if (!x) return;
    if (x == 1) return p1[0] = p2[0] = 0, void();
    if (x == 2) return p1[0] = p2[1] = 0, p1[1] = p2[0] = 1, void();

    int l = 1, n = 0, k;
    while ((l << 1) <= x) l <<= 1, n++; k = x - l;
    C(k, p1, p1 + l);
    for (int i = 0; i < k; i++) p1[i] += l;

    D(n, k, p2 + l, p2);
    for (int i = l; i < x; i++) p2[i] += l;
    for (int i = x; i < (l << 1); i++) p1[i - l] = p2[i];
}

int p1[maxn], p2[maxn], p[maxn];
bool vis[maxn];

void work()
{
    int n; cin >> n;
    for (int i = 0; i < n; i++) vis[i] = 0;
    if (n == 1) return cout << "Yes\n0\n0\n", void();
    if (n & 3) return cout << "No\n", void();
    C(n / 4, p1, p2);
    for (int i = 0; i < n / 4; i++)
    {
        int a = (i << 2), b = a | 1, c = a | 2, d = b | 2;
        p[a] = p1[i] << 2, p[b] = (p1[i] << 2) | 2;
        if (vis[p[a] ^ a] || vis[p[b] ^ b]) p[a] ^= 2, p[b] ^= 2;
        vis[p[a] ^ a] = vis[p[b] ^ b] = 1;

        p[c] = (p2[i] << 2) | 3, p[d] = (p2[i] << 2) | 1;
        if (vis[p[c] ^ c] || vis[p[d] ^ d]) p[c] ^= 2, p[d] ^= 2;
        vis[p[c] ^ c] = vis[p[d] ^ d] = 1;
    }

    cout << "Yes\n";
    for (int i = 0; i < n; i++) cout << i << " "; cout << "\n";
    for (int i = 0; i < n; i++) cout << p[i] << " "; cout << "\n";
}

int main()
{
    ios::sync_with_stdio(false), cin.tie(0);
    int T; cin >> T;
    while (T--) work();
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
3
4

output:

No
Yes
0 1 2 3 
0 2 3 1 

result:

ok Correct. (2 test cases)

Test #2:

score: 0
Accepted
time: 32ms
memory: 3620kb

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 2 7 5 6 4 1 3 
No
No
No
Yes
0 1 2 3 4 5 6 7 8 9 10 11 
8 10 7 5 4 6 1 3 2 0 11 9 
No
No
No
Yes
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 
0 2 11 9 6 4 13 15 12 14 7 5 10 8 1 3 
No
No
No
Yes
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18...

result:

ok Correct. (1999 test cases)

Test #3:

score: 0
Accepted
time: 44ms
memory: 3716kb

input:

828
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2...

output:

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 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 10...

result:

ok Correct. (828 test cases)

Test #4:

score: 0
Accepted
time: 169ms
memory: 5092kb

input:

10
200000
199996
199992
199988
199984
199980
199976
199972
199968
199964

output:

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 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 10...

result:

ok Correct. (10 test cases)

Test #5:

score: 0
Accepted
time: 172ms
memory: 4380kb

input:

17
114516
114492
114468
114444
114420
114396
114372
114348
114324
114300
114276
114252
114228
114204
114180
114156
114132

output:

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 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 10...

result:

ok Correct. (17 test cases)

Test #6:

score: 0
Accepted
time: 156ms
memory: 4712kb

input:

15
131072
130944
130816
130688
130560
130432
130304
130176
130048
129920
129792
129664
129536
129408
129280

output:

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 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 10...

result:

ok Correct. (15 test cases)

Test #7:

score: 0
Accepted
time: 171ms
memory: 4592kb

input:

15
131068
131004
130940
130876
130812
130748
130684
130620
130556
130492
130428
130364
130300
130236
130172

output:

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 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 10...

result:

ok Correct. (15 test cases)

Test #8:

score: 0
Accepted
time: 166ms
memory: 4580kb

input:

15
131064
131032
131000
130968
130936
130904
130872
130840
130808
130776
130744
130712
130680
130648
130616

output:

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 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 10...

result:

ok Correct. (15 test cases)

Test #9:

score: 0
Accepted
time: 40ms
memory: 4504kb

input:

15
131060
131059
131058
131057
131056
131055
131054
131053
131052
131051
131050
131049
131048
131047
131046

output:

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 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 10...

result:

ok Correct. (15 test cases)

Test #10:

score: 0
Accepted
time: 85ms
memory: 5736kb

input:

30
65536
65534
65532
65530
65528
65526
65524
65522
65520
65518
65516
65514
65512
65510
65508
65506
65504
65502
65500
65498
65496
65494
65492
65490
65488
65486
65484
65482
65480
65478

output:

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 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 10...

result:

ok Correct. (30 test cases)

Extra Test:

score: 0
Extra Test Passed