QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#67594 | #5098. 第一代图灵机 | sycqwq | 0 | 31ms | 13148kb | C++14 | 2.6kb | 2022-12-10 19:40:44 | 2022-12-10 19:40:46 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e5+5;
int n,m,q,b[maxn],c[maxn],bk[maxn],sum[maxn<<1];
struct node
{
int lans,nx;
}a[maxn<<2];
int query(int l,int r,int rt,int rmin)
{
if(l==r)
return sum[min(rmin,a[rt].nx)-1]-sum[l-1];
int mid=l+r>>1,rc=rt<<1|1;
// cout<<"###"<<l<<' '<<r<<' '<<rmin<<' '<<a[rc].nx<<endl;
if(a[rc].nx>=rmin)
return max(sum[rmin-1]-sum[mid],query(l,mid,rt<<1,rmin));
else
return max(a[rt].lans,query(mid+1,r,rt<<1|1,rmin));
}
void pushup(int l,int r,int rt)
{
int mid=l+r>>1;
a[rt].nx=min(a[rt<<1].nx,a[rt<<1|1].nx);
a[rt].lans=query(l,mid,rt<<1,a[rt<<1|1].nx);
// cout<<"QWQ"<<l<<' '<<r<<' '<<a[rt].lans<<' '<<a[rt].nx<<endl;
}
void update(int l,int r,int rt,int x,int y)
{
// cout<<"***"<<l<<' '<<r<<' '<<rt<<' '<<x<<' '<<y<<endl;
if(l==r)
return a[rt].nx=y,void();
int mid=l+r>>1;
if(x<=mid)
update(l,mid,rt<<1,x,y);
else
update(mid+1,r,rt<<1|1,x,y);
pushup(l,r,rt);
}
int rmin;
int queryANS(int l,int r,int rt,int x,int y)
{
if(x<=l&&r<=y)
{
int mid=l+r>>1,ans=query(l,mid,rt<<1,rmin);
rmin=min(rmin,a[rt].nx);
return ans;
}
int mid=l+r>>1,s=0;
if(mid<y)
s=max(s,queryANS(mid+1,r,rt<<1|1,x,y));
if(x<=mid)
s=max(s,queryANS(l,mid,rt<<1,x,y));
return s;
}
set<int> col[maxn];
void change(int x,int y)
{
auto it=col[y].lower_bound(x);
update(1,n,1,x,*it);
if(it!=col[y].begin())
update(1,n,1,*(--it),x);
it=col[c[x]].upper_bound(x);
if(it!=col[c[x]].begin())
{
auto it2=it;
--it;
if(it!=col[c[x]].begin())
{
--it;
update(1,n,1,*it,*it2);
}
}
c[x]=y;
}
int main()
{
// freopen("a.in","r",stdin);
// freopen("a.out","w",stdout);
cin>>n>>m>>q;
for(int i=1;i<=n;sum[i]=sum[i-1]+b[i],i++)
cin>>b[i];
for(int i=1;i<=m;i++)
col[i].insert(n+1);
for(int i=1;i<=n;col[c[i]].insert(i),i++)
cin>>c[i];
for(int i=1;i<=n;i++)
{
update(1,n,1,i,*col[c[i]].upper_bound(i));
// cout<<i<<' '<<(*col[c[i]].upper_bound(i))<<endl;
}
// cout<<"QWQ"<<q<<endl;
for(int i=1;i<=q;i++)
{
int op,x,y;
cin>>op>>x>>y;
if(op==1)
{
rmin=y+1;
cout<<queryANS(1,n,1,x,y)<<endl;
// cout<<"QWQ"<<endl;
}
else
change(x,y);
}
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 31ms
memory: 13148kb
input:
5000 200 5000 2315 3433 1793 4621 4627 4561 289 4399 3822 2392 392 4581 2643 2441 4572 4649 2981 3094 4206 2057 761 2516 2849 3509 3033 658 4965 3316 3269 4284 4961 753 1187 2515 1377 1725 4743 4761 3823 3464 4859 989 2401 953 875 1481 2181 103 2067 2625 3296 4721 61 3843 1607 997 4385 1284 4299 441...
output:
1573442 233573 162475 256573 472243 165017 233573 225126 301027 837514 472243 233573 1573442 860879 128064 345473 118688 131181 102482 335496 860879 1573442 1573442 36813 390346 1573442 131317 860879 98264 154645 225126 175714 1573442 1573442 860879 225126 1573442 860879 1573442 26617 1573442 419867...
result:
wrong answer 1st lines differ - expected: '118571', found: '1573442'
Subtask #2:
score: 0
Runtime Error
Test #3:
score: 0
Runtime Error
input:
200000 10 200000 55651 97298 108697 86619 60721 199951 10610 162267 154301 138848 39191 18605 101369 57073 34977 101576 71252 143401 89587 160521 166491 38442 150761 35579 25571 121311 38033 38483 144639 41401 179161 54872 157905 137601 46863 187656 171901 43715 41036 150741 69057 102031 130561 4772...
output:
3179037 3552279 1232419 2018806821 1380809049 2125700494 3844301 5253394 1838910530 5831072 1871935 6385255 1601687 1530548296 496473170 3649741 1206368 4347260 1773371 1258808 3005657 1766988 10467999 1204833401
result:
Subtask #3:
score: 0
Runtime Error
Test #5:
score: 0
Runtime Error
input:
200000 20000 200000 30681 32496 35471 48191 159123 69792 120915 150673 187226 158493 36275 26856 107976 124777 145229 69745 183961 14497 144808 153612 185893 137681 66417 46802 19345 113322 168046 128149 191001 135433 13201 139214 59489 81178 42343 163158 110121 119201 97501 53079 158755 192241 1132...
output:
645153475 1261933031 317164921 1157826026 172498488 1251387461 641343769 930943678 645856825 631840161 52649250 755303547 645153475 930943678 1891091504 654017982 638207031 654017982 1261933031 1050280879 484649198 770266818 2139863041 336108318 1251387461 631840161 1261933031 60038977 930943678 125...
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%