QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#67603 | #5098. 第一代图灵机 | sycqwq | 0 | 36ms | 13236kb | C++14 | 2.6kb | 2022-12-10 19:50:54 | 2022-12-10 19:50:56 |
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,r,rt,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);
}
}
col[c[x]].erase(col[c[x]].lower_bound(x));
col[y].insert(x);
c[x]=y;
}
int main()
{
// freopen("a.in","r",stdin);
// freopen("a.out","w",stdout);
ios::sync_with_stdio(0);cin.tie(0);
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<<"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;
}
else
change(x,y);
}
return 0;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 36ms
memory: 13236kb
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:
118571 90725 79596 95154 95154 94493 72411 100567 100567 100567 100567 90725 100567 100567 90725 118571 94493 95154 58191 118571 100567 100567 100567 39374 89208 118571 99923 100567 100567 95724 87252 100567 118571 100567 100567 100567 100567 100567 100567 26617 100567 99923 100567 118571 100567 100...
result:
wrong answer 1283rd lines differ - expected: '78580', found: '69577'
Subtask #2:
score: 0
Time Limit Exceeded
Test #3:
score: 0
Time Limit Exceeded
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:
1232419 1222519 1232419 1232419 1232419 1232419 1232419 1232419 1232419 1232419 1040511 1148070 1232419 1232419 1232419 1232419 1206368 1206368 1232419 1232419 1232419 1222519 1167757 1206368 1214212 1222519 1232419 1222519 1222519 1160928 1011843 1232419 1232419 1189403 1222519 1232419 1222519 1148...
result:
Subtask #3:
score: 0
Time Limit Exceeded
Test #5:
score: 0
Time Limit Exceeded
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:
46702944 46702944 38383720 38615532 38615532 42801975 39035571 46702944 46702944 46702944 27438528 38402892 46702944 46702944 42801975 42323113 39035571 42323113 46702944 46702944 46702944 41821993 46702944 34075405 46702944 38615532 46702944 28680653 46702944 42801975 42801975 38025842 46702944 467...
result:
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%