ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#166272 | #711. 子段与子段 | yhzsc | 100 | 226ms | 5872kb | C++ | 1.2kb | 2022-11-18 18:01:00 | 2022-11-18 18:01:02 |
answer
#include <iostream>
#include <cstdio>
using namespace std;
int n, m, l, r, ans;
const int N = 200010;
int a[N], s[N], t[N], p[N], ji[N], ou[N];
inline int read()
{
int res = 0; char ch = getchar(); bool XX = false;
for (; !isdigit(ch); ch = getchar())(ch == '-') && (XX = true);
for (; isdigit(ch); ch = getchar())res = (res << 3) + (res << 1) + (ch ^ 48);
return XX ? -res : res;
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= n; ++i)a[i] = read();
for (int i = 1; i <= n; ++i)s[i] = a[i] ^ s[i - 1];
for (int i = 1; i <= n; ++i)t[i] = s[i] ^ t[i - 1];
for (int i = 1; i <= n; ++i)p[i] = t[i] ^ p[i - 1];
for (int i = 1; i <= n; ++i)
if (i & 1)ji[i] = ji[i - 1] ^ s[i];
else ji[i] = ji[i - 1];
for (int i = 1; i <= n; ++i)
if (!(i & 1))ou[i] = ou[i - 1] ^ s[i];
else ou[i] = ou[i - 1];
while (m--)
{
l = read(); r = read(); ans = 0;
if ((r - l + 1) & 1)ans = t[r];
else ans = 0;
ans ^= (p[r - 1] ^ p[l - 2]);
if (!(r & 1))ans ^= ji[r - 1] ^ ji[max(l - 2, 0)];
else ans ^= ou[r - 1] ^ ou[max(l - 2, 0)];
printf("%d\n", ans);
}
return 0;
}
Details
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1204kb
input:
85 69 548813502 592844616 715189365 844265744 602763370 857945620 544883177 847251738 423654797 6235...
output:
0 644820523 728206291 0 28026074 0 0 0 42265468 0 0 573645098 500954349 0 25763698 42788921 80890296...
result:
ok 69 lines
Test #2:
score: 10
Accepted
time: 1ms
memory: 1212kb
input:
423 290 978570924 699479278 116201910 297436951 767023703 813797820 411820142 396505739 675439077 88...
output:
0 0 0 0 15173667 270991261 0 0 0 0 0 0 856326202 908298291 0 101426425 42160380 59000800 260244656 0...
result:
ok 290 lines
Test #3:
score: 10
Accepted
time: 0ms
memory: 1216kb
input:
378 454 133439431 354506059 96803952 657019776 343391726 652308955 591026897 821718566 659176476 402...
output:
48497967 591059471 404404026 0 738333728 0 334018354 32865220 0 97809127 0 326188438 1043273181 0 66...
result:
ok 454 lines
Test #4:
score: 10
Accepted
time: 1ms
memory: 1280kb
input:
3037 4378 417539200 908733438 781581726 735740086 693747026 265930487 916340332 145435607 259377388 ...
output:
901634558 0 0 0 0 0 0 474285889 0 0 0 0 696299071 784805072 0 46803501 964915993 636825670 0 0 83792...
result:
ok 4378 lines
Test #5:
score: 10
Accepted
time: 1ms
memory: 1316kb
input:
4999 5000 967530414 172693304 359512489 997981817 404660934 192181283 270965714 700750919 191655676 ...
output:
233505749 0 0 0 873105880 574346565 0 1014397574 108153191 482676417 531833433 0 0 762965773 0 0 0 3...
result:
ok 5000 lines
Test #6:
score: 10
Accepted
time: 0ms
memory: 1320kb
input:
5000 3974 675120207 299084507 569184751 260345141 958619695 108295541 251585378 273711740 673245537 ...
output:
0 941965468 0 0 38177163 0 89848341 953769662 0 0 0 480289863 748731858 0 914889001 0 0 886263764 0 ...
result:
ok 3974 lines
Test #7:
score: 10
Accepted
time: 64ms
memory: 4924kb
input:
158743 198243 856178259 883873487 991830273 443193787 903900695 503226693 85996783 71587981 60920822...
output:
0 1051072233 0 0 0 125187100 0 0 0 203616101 0 0 0 502564850 718051204 0 594199400 434351573 6318355...
result:
ok 198243 lines
Test #8:
score: 10
Accepted
time: 34ms
memory: 3548kb
input:
100000 100000 721098242 656500803 61409187 805548033 814529341 519590328 15569063 100649386 15183930...
output:
0 0 526344193 1006669799 861749211 455141424 311704190 76194859 806179519 0 241745279 602543825 0 0 ...
result:
ok 100000 lines
Test #9:
score: 10
Accepted
time: 56ms
memory: 5872kb
input:
200000 200000 842131068 673388219 498522264 748121531 385261331 610188593 827387456 885226316 758584...
output:
0 464461358 0 782572104 1034543190 0 0 807622853 0 0 644596552 0 182745888 160929506 0 0 0 418645642...
result:
ok 200000 lines
Test #10:
score: 10
Accepted
time: 69ms
memory: 5868kb
input:
200000 200000 185214635 632101741 433544469 492815454 77281985 916988410 769930803 929871128 6818313...
output:
0 394243017 0 0 0 0 0 0 0 57870252 877958836 270221888 0 0 258304362 0 918873477 636696240 0 0 0 485...
result:
ok 200000 lines