QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#810796 | #5098. 第一代图灵机 | nullptr_qwq | 20 | 639ms | 62736kb | C++14 | 2.8kb | 2024-12-12 11:10:10 | 2024-12-12 11:10:14 |
Judging History
answer
// 私は猫です
#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define inf 1000000000
#define infll 1000000000000000000ll
#define pii pair<int,int>
#define rep(i,a,b,c) for(int i=(a);i<=(b);i+=(c))
#define per(i,a,b,c) for(int i=(a);i>=(b);i-=(c))
#define F(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define dF(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define cmh(sjy) while(sjy--)
#define lowbit(x) (x&(-x))
#define HH printf("\n")
#define eb emplace_back
#define poly vector<int>
#define SZ(x) ((int)x.size())
using namespace std;
template<typename T>inline void chkmax(T &x,const T &y){ x=std::max(x,y); }
template<typename T>inline void chkmin(T &x,const T &y){ x=std::min(x,y); }
const int mod=998244353,maxn=500005;
int pre[maxn],n,m,zsy,c[maxn];
#define ls (o<<1)
#define rs (o<<1|1)
ll sum[maxn],a[maxn];
int mx[maxn<<2];
set<int>st[maxn];
ll t1[maxn<<2],t2[maxn<<2];
ll dfs(int o,int l,int r,int lim){
if(l==r)return mx[o]>=lim?t1[o]:sum[l]-sum[lim];
int mid=(l+r)>>1;
if(mx[ls]>=lim)return max(t2[o],dfs(ls,l,mid,lim));
return max(sum[mid]-sum[lim],dfs(rs,mid+1,r,lim));
}
void build(int o,int l,int r){
if(l==r)return mx[o]=pre[l],t1[o]=t2[o]=sum[l]-sum[pre[l]],void();
int mid=(l+r)>>1; build(ls,l,mid),build(rs,mid+1,r);
mx[o]=max(mx[ls],mx[rs]),t1[o]=max(t1[rs],t2[rs]),t2[o]=dfs(rs,mid+1,r,mx[ls]);
}
void update(int o,int l,int r,int pos,int val){
if(l==r)return mx[o]=val,t1[o]=t2[o]=sum[l]-sum[val],void();
int mid=(l+r)>>1;
(pos<=mid)?update(ls,l,mid,pos,val):update(rs,mid+1,r,pos,val);
mx[o]=max(mx[ls],mx[rs]),t1[o]=max(t1[rs],t2[rs]),t2[o]=dfs(rs,mid+1,r,mx[ls]);
}
#define node pair<int,ll>
void query(int o,int l,int r,int ql,int qr,node &res){
if(ql<=l&&qr>=r)return chkmax(res.se,dfs(o,l,r,res.fi)),chkmax(res.fi,mx[o]),void();
int mid=(l+r)>>1;
if(ql<=mid)query(ls,l,mid,ql,qr,res);
if(qr>mid)query(rs,mid+1,r,ql,qr,res);
}
void solve(){
cin>>n>>m>>zsy;
F(i,1,n)cin>>a[i],sum[i]=sum[i-1]+a[i];
F(i,1,m)st[i].insert(0);
F(i,1,n)cin>>c[i],pre[i]=*--st[c[i]].end(),st[c[i]].insert(i);
build(1,1,n);
F(_,1,zsy){
int op,x,y; cin>>op>>x>>y;
if(!(op&1)){
if(c[x]==y)continue;
auto it=st[c[x]].find(x);
if(next(it)!=st[c[x]].end()){
int pos=*next(it);
update(1,1,n,pos,pre[pos]=*prev(it));
}
st[c[x]].erase(x),it=st[c[x]=y].lower_bound(x);
if(it!=st[y].end()){
int pos=*next(it);
update(1,1,n,pos,pre[pos]=x);
}
update(1,1,n,x,pre[x]=*prev(it)),st[y].insert(x);
}else{
node res=mkp(0,0);
update(1,1,n,x,x-1);
query(1,1,n,x,y,res);
update(1,1,n,x,pre[x]);
cout<<res.se<<endl;
}
}
}
signed main(){
ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
int zsy=1;
F(____,1,zsy)solve();
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 12ms
memory: 36888kb
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 201st lines differ - expected: '118571', found: '62704'
Subtask #2:
score: 0
Wrong Answer
Test #3:
score: 0
Wrong Answer
time: 633ms
memory: 61084kb
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:
wrong answer 139th lines differ - expected: '1189403', found: '1303740'
Subtask #3:
score: 20
Accepted
Test #5:
score: 20
Accepted
time: 639ms
memory: 61956kb
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:
ok 200000 lines
Test #6:
score: 20
Accepted
time: 614ms
memory: 61896kb
input:
200000 20000 200000 35105 74665 63960 162062 164953 63344 145369 115837 108866 61866 110690 123641 106889 65531 115933 163273 7531 128251 158561 169221 149787 40911 54465 92737 73473 10609 62701 89599 40007 40272 7318 129047 171198 90131 111281 85645 174001 140289 135851 26785 136485 31989 16313 888...
output:
43816163 35764822 45394839 45394839 45394839 43816163 45394839 43816163 40900280 38802753 45394839 45394839 43816163 34715395 45394839 43816163 43816163 45394839 43816163 45394839 45394839 43816163 35764822 45394839 43816163 43816163 16638306 45394839 35764822 45394839 34921501 45394839 45394839 409...
result:
ok 200000 lines
Test #7:
score: 20
Accepted
time: 613ms
memory: 62736kb
input:
200000 20000 200000 80203 178041 44172 21001 54489 120807 60663 147301 166763 49071 98913 115641 30627 164382 54165 165057 46105 9628 57953 86346 8273 137848 44871 119728 107309 132201 72483 198451 58505 185062 27039 49401 172444 101505 180973 59256 44859 53105 195233 161425 132423 2566 189331 15869...
output:
44318499 33827474 43556508 44318499 43556508 38914187 44318499 43556508 47858466 44318499 40709211 43556508 35706654 43556508 44318499 44318499 47858466 44318499 35359541 43556508 43556508 43556508 47858466 31755901 43556508 44318499 43556508 43556508 44318499 44318499 44318499 44318499 43556508 443...
result:
ok 200000 lines
Test #8:
score: 20
Accepted
time: 635ms
memory: 60936kb
input:
200000 20000 200000 69757 155771 81753 9285 168151 179881 122502 198324 140481 33185 155861 173423 117211 80727 63754 167913 121921 185921 182266 24801 167005 191511 77176 176741 117041 42534 10209 6241 83970 67652 164225 155249 125057 23841 71911 133150 79732 125061 7111 29841 142343 129299 155501 ...
output:
54623112 54623112 54623112 36983972 41889300 49604086 43664569 54623112 42438674 39404039 43664569 35418806 43664569 54623112 49604086 49604086 42438674 54623112 54623112 33869050 54623112 42438674 36847615 39404039 54623112 54623112 43664569 49604086 42438674 54623112 54623112 43664569 49604086 424...
result:
ok 200000 lines
Subtask #4:
score: 0
Skipped
Dependency #1:
0%
Subtask #5:
score: 0
Skipped
Dependency #4:
0%