QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#424614 | #5022. 【模板】线段树 | 2745518585 | 0 | 2157ms | 28476kb | C++20 | 3.7kb | 2024-05-29 14:21:03 | 2024-05-29 14:21:04 |
Judging History
answer
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
const int N=1000001,M=500;
int n,m,q,t,d[N],e[N],f[N],f2[N],g[N],g2[N],h[N];
vector<pair<int,int>> b[N],c[N];
struct
{
int l,r;
}a[N];
void solve(int l,int r)
{
t=0;
for(int i=l+1;i<=r;++i)
{
d[++t]=a[i].l,d[++t]=a[i].r;
for(auto j:b[i]) d[++t]=j.first;
}
d[++t]=n;
sort(d+1,d+t+1);
t=unique(d+1,d+t+1)-d-1;
for(int i=1;i<=t;++i) c[i].clear();
for(int i=l+1;i<=r;++i)
{
for(auto j:b[i])
{
c[lower_bound(d+1,d+t+1,j.first)-d].push_back(make_pair(i,j.second));
}
}
for(int i=l;i<=r;++i) g[i]=0;
for(int i=1;i<=n;++i) f2[i]=0;
// printf("%d %d:\n",l,r);
for(int i=1;i<=t;++i)
{
for(int j=r;j>=l-1;--j) g[j]^=g[j-1];
int v=0;
g[0]=g[l];
for(int j=l+1;j<=r;++j)
{
if(a[j].l<d[i]&&a[j].r>=d[i]) g[++v]=g[j];
else g[v]^=g[j];
}
for(int j=0;j<=v;++j) g2[j]=0;
{
for(int j=0;j<=max(d[i]-d[i-1],v);++j) h[j]=0;
for(int j=d[i-1]+1;j<=d[i];++j) h[d[i]-j]^=f[j];
for(int j=1;j<=max(d[i]-d[i-1],v);j*=2)
{
for(int k=0;k<=max(d[i]-d[i-1],v);++k)
{
if(k&j) h[k]^=h[k^j];
}
}
for(int j=0;j<=v;++j) g2[j]^=h[j];
}
{
for(int j=0;j<=d[i]-d[i-1];++j) h[j]=0;
for(int j=d[i-1]+1;j<=d[i];++j) h[j-d[i-1]]^=f[j];
for(int j=1;j<=d[i]-d[i-1];j*=2)
{
if((v&j)==0) continue;
for(int k=d[i]-d[i-1];k>=j;--k) h[k]^=h[k-j];
}
for(int j=d[i-1]+1;j<=d[i];++j) f2[j]^=h[j-d[i-1]];
}
{
for(int j=0;j<=max(d[i]-d[i-1],v);++j) h[j]=0;
for(int j=0;j<=v;++j) h[v-j]^=g[j];
for(int j=1;j<=max(d[i]-d[i-1],v);j*=2)
{
for(int k=0;k<=max(d[i]-d[i-1],v);++k)
{
if(k&j) h[k^j]^=h[k];
}
}
for(int j=d[i-1]+1;j<=d[i];++j) f2[j]^=h[j-d[i-1]];
}
{
for(int j=0;j<=v;++j) h[j]=0;
for(int j=0;j<=v;++j) h[j+(d[i]-d[i-1])]^=g[j];
for(int j=1;j<=v;j*=2)
{
if(((d[i]-d[i-1])&j)!=0) continue;
for(int k=v;k>=j;--k) h[k]^=h[k-j];
}
for(int j=0;j<=v;++j) g2[j]^=h[j];
}
v=0;
g[l]=g2[0];
for(int j=l+1;j<=r;++j)
{
if(a[j].l<d[i]&&a[j].r>=d[i]) g[j]=g2[++v];
else g[j]=g2[v];
}
for(auto j:c[i])
{
e[j.second]=g[j.first];
}
// printf("%d: ",d[i]);
// for(int i=l;i<=r;++i) printf("%d ",g[i]);printf("\n");
}
swap(f,f2);
}
int main()
{
scanf("%*d%d%d",&n,&q);
for(int i=1;i<=n;++i)
{
scanf("%d",&f[i]);
}
for(int i=1;i<=q;++i)
{
int z;
scanf("%d",&z);
if(z==1)
{
++m;
scanf("%d%d",&a[m].l,&a[m].r);
--q,--i;
}
else if(z==2)
{
int x;
scanf("%d",&x);
b[m].push_back(make_pair(x,i));
}
}
for(auto i:b[0])
{
e[i.second]=f[i.first];
}
for(int i=0;i<=(m-1)/M;++i)
{
solve(i*M,min((i+1)*M,m));
}
for(int i=1;i<=q;++i)
{
printf("%d\n",e[i]);
}
for(int i=1;i<=n;++i)
{
printf("%d\n",f[i]);
}
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 8
Accepted
time: 0ms
memory: 24368kb
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: 3ms
memory: 22364kb
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: 3ms
memory: 23240kb
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 675770194 490547919 356133105 924706625 185332164 524956121 690079117 139294727 866385688 68236294 705877123 1037482711 732691981 1072016040 205006170 694314356 733017733 113225425 65199929 983529101 717179143 255628957 890702836 894793705 666710846 276321083 1012586084 166061298 ...
result:
wrong answer 3rd numbers differ - expected: '120274311', found: '675770194'
Subtask #2:
score: 0
Wrong Answer
Test #6:
score: 4
Accepted
time: 994ms
memory: 28476kb
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 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 0 0 0 ...
result:
wrong answer 486th numbers differ - expected: '0', found: '734489692'
Subtask #3:
score: 0
Wrong Answer
Test #10:
score: 0
Wrong Answer
time: 969ms
memory: 26556kb
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 0 0 1 0 0 0 0 1 1 0 1 1 0 1 0 1 1 1 0 1 1 1 0 1 1 1 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 1 0 1 1 0 1 1 0 0 1 0 1 0 1 0 1 1 1 1 0 0 0 1 1 0 0 0 1 1 1 0 1 1 1 1 1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 0 0 0 1 0 1 1 1 1 1 1 0 1 1 1 1 1 0 1 1 0 ...
result:
wrong answer 565th numbers differ - expected: '0', found: '1'
Subtask #4:
score: 0
Wrong Answer
Test #14:
score: 0
Wrong Answer
time: 1220ms
memory: 26568kb
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 523rd numbers differ - expected: '268419060', found: '422914801'
Subtask #5:
score: 0
Wrong Answer
Test #18:
score: 0
Wrong Answer
time: 1614ms
memory: 23820kb
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 458063628 452329866 773393204 506664955 995290683 831024341 890990738 671012718 961629111 556500009 102303365 477227264 154697068 654612933 988537886 145954025 349675429 952755344 576499197 562321215 879742795 606880290 1006459039 317537601 168013952 592470517 765610807 194865906 106591309...
result:
wrong answer 2nd numbers differ - expected: '717285236', found: '458063628'
Subtask #6:
score: 0
Skipped
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #5:
0%
Subtask #8:
score: 0
Skipped
Dependency #1:
0%