用户输出
40
1023
24
987
24
0
991
1023
1023
56
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#113972 | #1398. 与或和的异或 | Accepted | 100 | 764 ms | 16712 K | C++ 11 / 862 B | slayerzzj | 2024-07-14 15:10:41 |
#include <bits/stdc++.h>
using namespace std;
int n, m, a[100005], Sand[100005][20], Sor[100005][20];
int qand(int l, int r) {
int len = log(r - l) / log(2);
return Sand[l][len] & Sand[r - (1 << len) + 1][len];
}
int qor(int l, int r) {
int len = log(r - l) / log(2);
return Sor[l][len] | Sor[r - (1 << len) + 1][len];
}
inline int read_() {
int ret = 0, f = 1;
char ch = getchar();
for (; ch < '0' || ch > '9'; ch = getchar())
if (ch == '-')
f = -f;
for (; ch >= '0' && ch <= '9'; ch = getchar()) ret = (ret << 1) + (ret << 3) + (ch ^ 48);
return ret * f;
}
int main() {
n = read_();
m = read_();
for (int i = 1; i <= n; i++) Sand[i][0] = Sor[i][0] = a[i] = read_();
for (int j = 1; j <= log(n) / log(2); j++)
for (int i = 1; i <= n - (1 << j) + 1; i++)
Sand[i][j] = Sand[i][j - 1] & Sand[i + (1 << j - 1)][j - 1],
Sor[i][j] = Sor[i][j - 1] | Sor[i + (1 << j - 1)][j - 1];
int l, r;
for (int i = 1; i <= m; i++) {
l = read_(), r = read_();
printf("%d\n", qand(l, r) ^ qor(l, r));
}
return 0;
}
用户输出
40
1023
24
987
24
0
991
1023
1023
56
系统信息
Exited with return code 0
100 100
448 0 73737727 602931199 73741822 73741822 73741822 516351 0 73741807 73741822 262143 0 0 73
<1159 bytes omitted>
1073741823
479906304
1073741823
1023410175
1073741823
1023410175
1073741823
1073741823
1073741823
10
<948 bytes omitted>
用户输出
1073741823
479906304
1073741823
1023410175
1073741823
1023410175
1073741823
1073741823
1073741823
1073741823
1073741823
73793535
<920 bytes omitted>
系统信息
Exited with return code 0
1000 1000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 73709055 73741822 73741822 73741822 73741822 73741822 73741822
<12851 bytes omitted>
75446271
75446271
1073741823
536870911
536870911
1073741823
536870911
0
1073741823
536870911
1073741
<10093 bytes omitted>
用户输出
75446271
75446271
1073741823
536870911
536870911
1073741823
536870911
0
1073741823
536870911
1073741823
620756991
939524095
8388
<10065 bytes omitted>
系统信息
Exited with return code 0
3000 3000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 73741567 73741822 73741822 73741822 73741822 73741
<44044 bytes omitted>
73793535
536870911
1073741823
1073741823
1073741823
73741823
1073741823
1073741823
610795519
0
53687
<30300 bytes omitted>
用户输出
73793535
536870911
1073741823
1073741823
1073741823
73741823
1073741823
1073741823
610795519
0
536870911
1073741823
1073741823
1
<30272 bytes omitted>
系统信息
Exited with return code 0
3000 3000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 737418
<44622 bytes omitted>
1073741823
939524095
939524095
73610751
73741823
1073741823
939524095
805306367
73872895
1073741823
<29285 bytes omitted>
用户输出
1073741823
939524095
939524095
73610751
73741823
1073741823
939524095
805306367
73872895
1073741823
939524095
125646335
10737418
<29257 bytes omitted>
系统信息
Exited with return code 0
100000 100000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<1715989 bytes omitted>
134217727
134217727
671088639
134217727
134217727
75497471
134217727
134217727
132464639
134217727
1
<950853 bytes omitted>
用户输出
134217727
134217727
671088639
134217727
134217727
75497471
134217727
134217727
132464639
134217727
134217727
132464639
75497471
<950825 bytes omitted>
系统信息
Exited with return code 0
100000 100000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<1777038 bytes omitted>
0
1073741823
536870911
536870911
805306367
536870911
268435455
536870911
1073741823
536870911
107374
<1003012 bytes omitted>
用户输出
0
1073741823
536870911
536870911
805306367
536870911
268435455
536870911
1073741823
536870911
1073741823
536870911
536870911
107
<1002984 bytes omitted>
系统信息
Exited with return code 0
100000 100000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<1721061 bytes omitted>
73742335
939524095
1073741823
1073741823
83886079
1073741823
1073741823
1073741823
1073741823
739246
<982751 bytes omitted>
用户输出
73742335
939524095
1073741823
1073741823
83886079
1073741823
1073741823
1073741823
1073741823
73924607
73742335
939524095
0
1073
<982723 bytes omitted>
系统信息
Exited with return code 0
100000 1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<12313367 bytes omitted>
134217727
268435455
134217727
0
73741823
75497471
268435455
73741823
268435455
671088639
134217727
1
<9575301 bytes omitted>
用户输出
134217727
268435455
134217727
0
73741823
75497471
268435455
73741823
268435455
671088639
134217727
1073741823
268435455
26843545
<9575273 bytes omitted>
系统信息
Exited with return code 0
100000 1000000
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
<12341878 bytes omitted>
0
1073741823
1073741823
1073741823
1073741823
939524095
1073741823
1073741823
268435455
125829119
10
<10119387 bytes omitted>
用户输出
0
1073741823
1073741823
1073741823
1073741823
939524095
1073741823
1073741823
268435455
125829119
1073741823
73924607
1073741823
<10119359 bytes omitted>
系统信息
Exited with return code 0