251838
100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2
<6166055 bytes omitted>
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#31192 | #1162. 异或 | Time Limit Exceeded | 50 | 10131 ms | 14924 K | C++ 11 (Clang) / 1.2 K | 软件82-王成昊 | 2020-07-04 1:05:20 |
#include <bits/stdc++.h>
using namespace std;
int a[300005], b[300005];
unordered_map<int, int> mm;
struct query {
int l, r, lw, rw, id;
int ans;
} q[300005];
bool cmp(query x, query y) { return (x.lw != y.lw) ? (x.lw < y.lw) : (x.rw < y.rw); }
bool cmpp(query x, query y) { return x.id < y.id; }
int main() {
// freopen("xor1.in","r",stdin);
// freopen("xor1.out","w",stdout);
int n, m;
scanf("%d", &n);
int base = sqrt(n);
for (int i = 1; i <= n; ++i) scanf("%d", &a[i]), b[i] = b[i - 1] ^ a[i];
scanf("%d", &m);
for (int i = 1; i <= m; ++i) {
scanf("%d%d", &q[i].l, &q[i].r);
q[i].lw = q[i].l / base;
q[i].rw = q[i].r / base;
q[i].id = i;
}
sort(q + 1, q + 1 + m, cmp);
int l = 1, r = 0;
long long now = 0;
for (int i = 1; i <= m; ++i) {
while (r < q[i].r) {
++r;
++mm[a[r]];
if (mm[a[r]] == 1)
now ^= a[r];
}
while (l > q[i].l) {
--l;
++mm[a[l]];
if (mm[a[l]] == 1)
now ^= a[l];
}
while (r > q[i].r) {
--mm[a[r]];
if (!mm[a[r]])
now ^= a[r];
--r;
}
while (l < q[i].l) {
--mm[a[l]];
if (!mm[a[l]])
now ^= a[l];
++l;
}
q[i].ans = now ^ b[q[i].r] ^ b[q[i].l - 1];
}
sort(q + 1, q + 1 + m, cmpp);
for (int i = 1; i <= m; ++i) printf("%d\n", q[i].ans);
return 0;
}
251838
100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2
<6166055 bytes omitted>
256041
100 200 300 400 500 600 700 800 900 1000 1100 1200 1300 1400 1500 1600 1700 1800 1900 2000 2
<5984493 bytes omitted>
907
56 71 13 4 45 57 55 89 12 58 95 99 45 100 42 94 89 94 16 18 55 67 5 68 20 43 51 93 84 92 77 63
<10826 bytes omitted>
113
37
35
10
30
69
105
16
64
123
87
73
4
0
91
1
90
94
2
77
118
12
16
48
123
<3772 bytes omitted>
用户输出
113
37
35
10
30
69
105
16
64
123
87
73
4
0
91
1
90
94
2
77
118
12
16
48
123
69
66
35
48
65
8
48
58
50
79
44
16
60
122
12
4
112
2
<2799 bytes omitted>
系统信息
Exited with return code 0
911
79 65 67 71 96 98 41 89 63 100 54 9 66 92 97 89 64 44 2 38 94 94 37 91 17 26 38 13 87 96 5 75 1
<10954 bytes omitted>
5
68
32
111
15
52
104
119
29
42
98
104
33
104
23
13
57
16
41
81
5
109
53
6
7
<3840 bytes omitted>
用户输出
5
68
32
111
15
52
104
119
29
42
98
104
33
104
23
13
57
16
41
81
5
109
53
6
73
15
109
105
104
92
2
53
47
102
66
83
94
91
85
100
1
<2854 bytes omitted>
系统信息
Exited with return code 0
910
96 10 58 93 18 79 68 66 20 19 79 50 22 92 79 6 85 16 57 4 81 43 21 39 74 59 34 84 86 39 24 2 6
<10840 bytes omitted>
105
19
114
5
48
41
33
108
26
10
108
49
87
48
68
38
110
68
52
4
14
13
120
118
<3759 bytes omitted>
用户输出
105
19
114
5
48
41
33
108
26
10
108
49
87
48
68
38
110
68
52
4
14
13
120
118
107
12
35
67
58
76
90
21
58
9
105
87
62
59
41
51
40
<2788 bytes omitted>
系统信息
Exited with return code 0
908
82 94 2 44 73 45 58 30 18 39 80 54 88 81 37 7 99 59 65 93 22 20 35 57 60 37 46 20 59 88 99 41 3
<11278 bytes omitted>
0
60
0
91
79
122
121
78
115
41
103
2
31
59
96
114
23
98
62
45
50
62
122
78
9
<3988 bytes omitted>
用户输出
0
60
0
91
79
122
121
78
115
41
103
2
31
59
96
114
23
98
62
45
50
62
122
78
95
96
121
81
61
92
68
111
104
123
119
75
10
104
65
40
<2963 bytes omitted>
系统信息
Exited with return code 0
978
41 67 43 65 96 23 3 53 34 78 87 67 31 52 74 3 16 45 10 85 96 46 36 0 41 26 85 62 29 0 98 91 47
<10961 bytes omitted>
17
80
84
85
54
79
62
124
53
92
84
70
82
98
69
19
39
94
39
117
34
121
89
79
5
<3753 bytes omitted>
用户输出
17
80
84
85
54
79
62
124
53
92
84
70
82
98
69
19
39
94
39
117
34
121
89
79
52
0
59
59
113
99
82
39
82
57
111
84
14
86
93
55
90
6
<2789 bytes omitted>
系统信息
Exited with return code 0
962
299718210 299718210 0 39962428 59943642 559473992 219793354 939117058 159849712 999060700 97907
<17226 bytes omitted>
746812074
909717596
495511252
55402154
812639012
0
919969834
79389020
742767238
787403722
<9685 bytes omitted>
用户输出
746812074
909717596
495511252
55402154
812639012
0
919969834
79389020
742767238
787403722
945520388
1068797380
233603052
4395848
<8754 bytes omitted>
系统信息
Exited with return code 0
935
899154630 939117058 939117058 319699424 319699424 639398848 419605494 659380062 279736996 73930
<17186 bytes omitted>
934921578
489567608
451179490
711757202
879173416
69610634
818405958
154782278
137133528
31
<9859 bytes omitted>
用户输出
934921578
489567608
451179490
711757202
879173416
69610634
818405958
154782278
137133528
310552354
849410002
851616358
364033954
<8911 bytes omitted>
系统信息
Exited with return code 0
935
379643066 0 699342490 219793354 79924856 299718210 219793354 179830926 99906070 79924856 539492
<17019 bytes omitted>
352765180
138762976
649995032
331699740
1003139736
28540058
272635836
693480286
952284874
4
<9684 bytes omitted>
用户输出
352765180
138762976
649995032
331699740
1003139736
28540058
272635836
693480286
952284874
425278884
612072688
593203122
68810111
<8746 bytes omitted>
系统信息
Exited with return code 0
952
599436420 19981214 839210988 899154630 859192202 0 99906070 179830926 539492778 359661852 21979
<17213 bytes omitted>
103578644
618951634
383099418
248973264
889950206
51673546
58135816
239774568
597982474
168
<9751 bytes omitted>
用户输出
103578644
618951634
383099418
248973264
889950206
51673546
58135816
239774568
597982474
168596210
862628576
780260688
956305864
<8816 bytes omitted>
系统信息
Exited with return code 0
962
59943642 239774568 159849712 379643066 119887284 239774568 559473992 379643066 19981214 6393988
<17270 bytes omitted>
816843836
2171850
710812428
500992326
93317780
619242180
742511584
592153734
211465332
1070
<9659 bytes omitted>
用户输出
816843836
2171850
710812428
500992326
93317780
619242180
742511584
592153734
211465332
1070226742
862396096
788304070
455981652
<8726 bytes omitted>
系统信息
Exited with return code 0
293327
0 1 0 1 1 0 0 1 1 1 1 0 1 1 1 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 0
<4452780 bytes omitted>
268065
0 0 1 1 0 0 1 0 1 1 0 1 0 0 0 1 0 1 0 0 0 1 0 1 0 1 0 0 1 0 0 0 0 1 0 1 1 0 1 0 0 0 0 0 0 0
<4495021 bytes omitted>
273128
1 0 1 1 0 0 1 1 1 0 1 1 1 1 0 1 0 0 0 0 0 1 0 0 1 0 1 1 1 0 1 0 0 0 1 0 1 1 1 0 0 1 1 0 1 0
<4438785 bytes omitted>
256076
0 0 0 1 0 1 0 0 0 1 0 0 0 1 1 0 1 1 1 1 1 1 1 0 0 1 1 0 1 1 1 1 1 0 0 0 1 1 1 1 1 0 1 1 1 1
<4077145 bytes omitted>
286020
1714284 1926072 1256742 1856142 2173824 271728 2259738 1616382 1978020 2221776 1566432 13826
<6399775 bytes omitted>
293085
1580418 1902096 733266 903096 2211786 699300 763236 721278 2229768 1146852 2149848 2259738 4
<6230057 bytes omitted>
289253
2293704 1626372 2283714 1954044 1040958 1056942 2289708 303696 1440558 1228770 2063934 90709
<5964250 bytes omitted>