結果
| 問題 |
No.3265 地元に帰れば天才扱い!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-06 20:25:34 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 324 ms / 2,500 ms |
| コード長 | 1,358 bytes |
| コンパイル時間 | 6,666 ms |
| コンパイル使用メモリ | 333,400 KB |
| 実行使用メモリ | 12,800 KB |
| 最終ジャッジ日時 | 2025-09-06 20:25:53 |
| 合計ジャッジ時間 | 17,704 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include<atcoder/all>
// using mint = atcoder::modint998244353;
using ld = long double;
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(int)(n);++i)
template<typename T>bool chmin(T&a,T b){return b<a?(a=b,1):0;}
template<typename T>bool chmax(T&a,T b){return b>a?(a=b,1):0;}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
long N,M;
cin>>N>>M;
vector<long> A(N),L(N),R(N),H(N);
rep(i,N) cin>>A[i]>>L[i]>>R[i],L[i]--,H[i]=i;
atcoder::fenwick_tree<long> b1(M),b2(M+1);
long now=0;
rep(i,N){
b1.add(i,A[i]);
b2.add(L[i],1);
b2.add(R[i],-1);
}
rep(i,N) now+=A[i]*(R[i]-L[i])-b1.sum(L[i],R[i]);
int Q;
cin>>Q;
while(Q--){
int x,y,u,v;
cin>>x>>y>>u>>v;
x--;y--;u--;
now-=A[x]*(R[x]-L[x])-b1.sum(L[x], R[x]);
now+=A[x]*(b2.sum(0, H[x]+1)-(L[x]<=H[x]&&H[x]<R[x]));
b1.add(H[x],-A[x]);
b2.add(L[x], -1);
b2.add(R[x], 1);
H[x]=y;
L[x]=u;
R[x]=v;
b1.add(H[x], A[x]);
b2.add(L[x], 1);
b2.add(R[x], -1);
now+=A[x]*(R[x]-L[x])-b1.sum(L[x], R[x]);
now-=A[x]*(b2.sum(0, H[x]+1)-(L[x]<=H[x]&&H[x]<R[x]));
cout<<now<<"\n";
}
}