QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#284038 | #5022. 【模板】线段树 | _ZMF_ | 0 | 1360ms | 18748kb | C++17 | 2.1kb | 2023-12-15 21:32:45 | 2023-12-15 21:32:46 |
Judging History
answer
/*
60 + 0 + 100 + 64 = 224.
*/
#include <bits/stdc++.h>
using namespace std;
//#define int long long
#define L(i, j, k) for (int i = (j); i <= (k); i++)
#define R(i, j, k) for (int i = (j); i >= (k); i--)
#define pb push_back
#define pii pair<int, int>
inline int read()
{
int sum = 0, nega = 1;
char ch = getchar();
while (ch > '9'||ch < '0')
{
if (ch == '-') nega = -1;
ch = getchar();
}
while (ch <= '9' && ch >= '0') sum = sum * 10 + ch - '0', ch = getchar();
return sum * nega;
}
const int N = 3e5 + 9, B = 256, lB = 8;
int a[N], n, q, L[N], R[N], id[N], b[N];
int f[N / B][B];
vector<int> G[N];
inline void build(int x)
{
int cnt = 0; int siz = G[x].size();
R(i, siz - 1, 0) b[++cnt] = G[x][i];
L(i, L[x], R[x]) b[++cnt] = a[i];
L(i, 0, lB - 1)
if(siz & (1 << i))
R(j, cnt, (1 << i)) b[j] ^= b[j - (1 << i)];
L(i, siz + 1, cnt) a[L[x] + i - (siz + 1)] = b[i];
L(i, L[x], R[x]) f[x][R[x] - i] = a[i];
for (int i = 1; i < B; i <<= 1)
for (int j = 0; j < B; j += i * 2)
for (int k = 0; k < i; k++)
f[x][i + j + k] ^= f[x][j + k];
G[x].clear();
return ;
}
inline void update(int l, int r)
{
if(id[l] == id[r])
{
build(id[l]);
R(i, r, l + 1) a[i] ^= a[i - 1];
build(id[l]); return ;
}
int nw = 0;
build(id[l]);
nw = a[R[id[l]]];
R(i, R[id[l]], l + 1) a[i] ^= a[i - 1];
build(id[l]);
L(i, id[l] + 1, id[r] - 1)
{
if(G[i].size() >= B - 1) build(i);
int siz = G[i].size();
int tmp = f[i][siz];
G[i].pb(nw);
nw = tmp;
}
build(id[r]);
R(i, r, L[id[r]] + 1) a[i] ^= a[i - 1];
a[L[id[r]]] ^= nw;
build(id[r]);
return ;
}
signed main()
{
int TC = read();
n = read(), q = read(); int nn = n;
L(i, 1, n) a[i] = read();
while(n % B != 0) a[++n] = 0;
L(i, 1, n) id[i] = (i - 1) / B + 1;
L(i, 1, n / B) L[i] = (i - 1) * B + 1, R[i] = i * B;
L(i, 1, id[n]) build(i);
L(i, 1, q)
{
int op = read();
if(op == 1)
{
int l = read(), r = read();
update(l, r);
}
else
{
int x = read();
build(id[x]);
printf("%d\n", a[x]);
}
}
L(i, 1, id[n]) build(i);
L(i, 1, nn) printf("%d\n", a[i]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 8
Accepted
time: 0ms
memory: 16008kb
input:
1 6 6 1 1 5 1 9 4 2 5 1 2 5 2 4 1 3 6 2 6 1 1 6
output:
9 4 12 1 0 5 4 12 0
result:
ok 9 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 17788kb
input:
1 999 997 898798734 979577086 45974352 1013270193 1053191143 533594258 372426673 947830633 122319874 368651315 866424479 109724831 427664962 558099346 764830489 326451620 322471751 525780385 746941281 670254345 586958579 979544209 743892216 436404384 291681381 979530194 998929567 367716728 909076993...
output:
1015342581 962986689 965094083 871356796 835210392 172023195 63088572 606096781 569607283 436055720 154605892 663158209 154605892 776365236 281312240 62398687 182713417 604764772 816533315 793514230 325061861 806973284 91749226 283750235 198953311 170342298 432592070 809908556 683302450 40932811 669...
result:
ok 1996 numbers
Test #3:
score: -8
Wrong Answer
time: 2ms
memory: 16520kb
input:
1 999 997 89872218 906651903 120274311 490547919 291584020 755757065 24942887 707247173 763024744 68250332 114193028 999245166 140381610 171802205 399965713 299821903 907998064 906075056 427270276 335420206 708713870 492555323 359637714 197212814 35225369 1011322274 912003632 633998134 1026276199 85...
output:
89872218 860962725 120274311 490547919 978745892 924706625 610771729 524956121 105748312 139294727 866385688 729638611 92178006 1037482711 80194776 277477501 592738191 694314356 733017733 701758468 65199929 983529101 717179143 542164040 444291361 439952700 147939819 276321083 1012586084 166061298 30...
result:
wrong answer 257th numbers differ - expected: '955317090', found: '230081639'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 0
Wrong Answer
time: 399ms
memory: 18544kb
input:
2 249998 99999 1048488450 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 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 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 0 0 0 0 0 0 0 0 ...
output:
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 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 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 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
wrong answer 2414th numbers differ - expected: '0', found: '1048488450'
Subtask #3:
score: 0
Wrong Answer
Test #10:
score: 0
Wrong Answer
time: 351ms
memory: 18748kb
input:
3 250000 99999 1 1 1 1 1 0 1 0 1 1 0 1 0 1 1 1 1 1 1 0 1 0 1 0 1 1 1 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 1 1 1 0 0 0 1 0 1 0 0 1 0 0 1 1 1 0 0 0 1 1 1 1 1 1 0 0 1 1 1 1 0 0 0 0 1 1 0 0 1 1 0 1 1 0 1 1 0 1 1 1 0 0 1 1 0 0 1 1 1 0 1 1 1 1 1 0 1 0 1 0 0 1 0 1 1 1 0 1 1 0 1 1 0 1 0 0 1 1...
output:
0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 1 0 0 0 0 1 1 0 1 1 0 1 0 1 1 1 0 1 1 1 0 1 1 0 1 1 1 1 0 1 0 0 0 1 1 0 1 0 0 1 1 0 1 0 0 0 0 1 1 1 0 1 1 0 0 0 1 1 0 1 0 1 1 0 0 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 0 1 1 0 0 0 1 1 0 1 0 1 1 1 0 1 1 1 0 1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 0 1 0 1 1 0 0 1 1 0 0 1 0 1 1 0 1 1 1 ...
result:
wrong answer 14th numbers differ - expected: '0', found: '1'
Subtask #4:
score: 0
Wrong Answer
Test #14:
score: 0
Wrong Answer
time: 709ms
memory: 18584kb
input:
4 249996 99997 309331355 195839266 912372930 57974187 363345291 954954162 650621300 389049294 821214285 263720748 231045308 844370953 768579771 664766522 681320982 124177317 32442094 297873605 743179832 1073656106 443742270 235746807 1054294813 974443618 422427461 307448375 1018255356 20105813 36821...
output:
611117059 866091251 300188933 0 478915924 1053588351 453142424 897441996 60971719 748656483 600408393 0 303761852 983037069 883016404 332332552 1069626159 860304528 851235295 561276840 389049294 681320982 484263000 351914192 620106464 667080579 733146026 375466744 0 347632358 737240082 321494160 0 3...
result:
wrong answer 175th numbers differ - expected: '109507699', found: '975113088'
Subtask #5:
score: 0
Wrong Answer
Test #18:
score: 0
Wrong Answer
time: 1360ms
memory: 18272kb
input:
5 249997 99997 860563869 428592873 58576739 761578583 47999879 294581118 988847649 569566599 640106250 440172702 178219106 966598261 763325707 846927552 877923116 145156535 246778542 25949847 507939778 116507169 555239769 259969305 328955819 171606729 535970481 121608060 4437163 370976515 713807003 ...
output:
860563869 717285236 452329866 773393204 485721677 965902221 831024341 890990738 455498944 92913689 556500009 102303365 264515518 445496274 654612933 988537886 165104807 364103659 952755344 576499197 775866335 1003839403 606880290 1006459039 1005979559 588810854 592470517 765610807 123827263 86327854...
result:
wrong answer 257th numbers differ - expected: '1050908706', found: '102074746'
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #5:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
0%