結果
| 問題 |
No.3265 地元に帰れば天才扱い!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-06 13:10:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 1,044 ms / 2,500 ms |
| コード長 | 1,206 bytes |
| コンパイル時間 | 1,065 ms |
| コンパイル使用メモリ | 78,012 KB |
| 実行使用メモリ | 31,104 KB |
| 最終ジャッジ日時 | 2025-09-06 13:13:04 |
| 合計ジャッジ時間 | 24,971 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#include<iostream>
#include<cassert>
#include<atcoder/lazysegtree>
using namespace std;
struct dat{
long s,b,w,len;
};
dat op(dat a,dat b){return(dat){a.s+b.s,a.b+b.b,a.w+b.w,a.len+b.len};}
dat e(){return(dat){0L,0L,0L,0};}
dat mp(long f,dat x)
{
x.w+=x.len*f;
x.s+=x.b*f;
return x;
}
long cmp(long f,long g){return f+g;}
long id(){return 0L;}
int N,M;
int A[2<<17],L[2<<17],R[2<<17],pos[2<<17];
int B[2<<17];
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>N>>M;
long P=0;
for(int i=0;i<N;i++)
{
cin>>A[i]>>L[i]>>R[i];
L[i]--;
P+=(long)A[i]*(R[i]-L[i]);
pos[i]=i;
}
vector<dat>init(M,(dat){0L,0L,0L,1});
for(int i=0;i<N;i++)
{
init[i].b=A[i];
}
atcoder::lazy_segtree<dat,op,e,long,mp,cmp,id>seg(init);
for(int i=0;i<N;i++)seg.apply(L[i],R[i],1);
int Q;cin>>Q;
for(;Q--;)
{
int x,y,u,v;cin>>x>>y>>u>>v;
x--,y--,u--;
P-=(long)A[x]*(R[x]-L[x]);
seg.apply(L[x],R[x],-1);
{
auto t=seg.get(pos[x]);
t.b=0;
t.s=0;
seg.set(pos[x],t);
}
L[x]=u,R[x]=v;pos[x]=y;
P+=(long)A[x]*(R[x]-L[x]);
seg.apply(L[x],R[x],1);
{
auto t=seg.get(pos[x]);
t.b=A[x];
t.s=t.b*t.w;
seg.set(pos[x],t);
}
cout<<P-seg.all_prod().s<<"\n";
}
}