QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#285491 | #5022. 【模板】线段树 | _ZMF_ | 0 | 4ms | 18768kb | C++17 | 2.3kb | 2023-12-16 19:41:33 | 2023-12-16 19:41:34 |
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 = 4, lB = 2;
int a[N], n, q, L[N], R[N], id[N], b[N], g[N];
int f[N / B][B];
vector<int> G[N];
inline void build(int x)
{
int cnt = 0; int siz = G[x].size();
int pep = 0;
L(i, 0, B - 1) g[i] = 0;
L(i, 0, siz - 1) g[pep++] = G[x][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++)
g[i + j] ^= g[i + j + k];
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, 1, cnt) a[L[x] + i - 1] = b[i];
L(i, L[x], R[x]) a[i] ^= g[i - L[x]];
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;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 8
Accepted
time: 0ms
memory: 17196kb
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: 17988kb
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: 4ms
memory: 18768kb
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 291584020 104641081 220236796 739970684 726034257 846685553 983874201 1026560651 896409377 740589583 53852016 889109628 690158212 812955038 246235268 295528665 852744433 430425601 412012451 575666987 109129033 694018027 816318775 859813172 306510688 187717426 1...
result:
wrong answer 5th numbers differ - expected: '978745892', found: '291584020'
Subtask #2:
score: 0
Time Limit Exceeded
Test #6:
score: 0
Time Limit Exceeded
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:
Subtask #3:
score: 0
Time Limit Exceeded
Test #10:
score: 0
Time Limit Exceeded
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 1 1 0 0 1 1 1 0 0 1 0 0 1 0 0 0 0 1 0 0 1 0 1 0 0 1 1 1 0 1 0 1 1 0 1 0 0 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 1 1 1 1 0 1 1 1 1 1 0 0 1 1 0 1 1 0 1 1 0 1 0 0 1 0 1 0 1 1 0 0 1 0 1 1 1 0 0 1 0 0 1 0 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 1 0 0 1 1 1 0 0 1 0 0 1 0 1 0 1 0 0 1 0 0 1 0 0 1 1 1 1 0 0 0 ...
result:
Subtask #4:
score: 0
Time Limit Exceeded
Test #14:
score: 0
Time Limit Exceeded
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 842879626 8473835 0 0 20105813 0 48208933 824388618 513895623 131608592 0 759935774 1045754671 181936366 312155638 1063400185 860304528 125018294 0 535343943 43748649 586815406 899343810 1047103496 23300336 223512581 78307047 0 45234858 67810507 0 0 897896217 0 0 0 302967870 436120645 7088...
result:
Subtask #5:
score: 0
Time Limit Exceeded
Test #18:
score: 0
Time Limit Exceeded
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:
result:
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #5:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
0%