結果
| 問題 |
No.3265 地元に帰れば天才扱い!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-09-10 10:09:22 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 3,975 bytes |
| コンパイル時間 | 5,597 ms |
| コンパイル使用メモリ | 259,424 KB |
| 実行使用メモリ | 11,108 KB |
| 最終ジャッジ日時 | 2025-09-10 10:10:00 |
| 合計ジャッジ時間 | 36,151 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | WA * 21 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep1(i,n) for(int i=1; i<=(n); i++)
#define sz(x) int(x.size())
#define all(x) (x).begin(),(x).end()
#define lINF ll(2e18)//LONG_LONG_MAX //ll
#define iINF int(2e9+100)//INT_MAX //int
#define yes "Yes"
#define no "No"
#define kotae cout<<ans<<endl;
#define dame { puts("-1"); return 0;}
#define dame0 { puts("0"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define db cout<<'@'<<endl;
#define el cout<<'\n';
#define pc(x) __builtin_popcount(x)
#define pcl(x) __builtin_popcountll(x)
using ll=long long;
using ull=unsigned long long;
using Pii=pair<int,int>;
using Pil=pair<int,ll>;
using Pli=pair<ll,int>;
using Pll=pair<ll,ll>;
using Pci=pair<char,int>;
using Pcl=pair<char,ll>;
template <typename T>
using pqg = priority_queue<T,vector<T>,greater<T>>;
using vi=vector<int>;
using vi2=vector<vector<int>>;
using vi3=vector<vector<vector<int>>>;
using vl=vector<ll>;
using vl2=vector<vector<ll>>;
using vl3=vector<vector<vector<ll>>>;
using vs=vector<string>;
using vpii=vector<Pii>;
using vpil=vector<Pil>;
using vpci=vector<Pci>;
using vpcl=vector<Pcl>;
using Ti=tuple<int,int,int>;
using vti=vector<Ti>;
void coutdouble(double x) { printf("%.10f\n", x); }
void coutvi(vi vec) { for (int k : vec)cout << k << ' '; cout << endl; return; }
void coutvl(vl vec) { for (ll k : vec)cout << k << ' '; cout << endl; return; }
void coutseti(set<int> st) { for (int k : st)cout << k << ' '; cout << endl; return; }
void coutsetl(set<ll> st) { for (ll k : st)cout << k << ' '; cout << endl; return; }
void chmax(int &a, int b){ a = max(a, b); return;}
void chmin(int &a, int b){ a = min(a, b); return;}
void chmaxl(ll &a, ll b){ a = max(a, b); return;}
void chminl(ll &a, ll b){ a = min(a, b); return;}
void rev(vi &a){ reverse(all(a)); return;}
template <typename T>
void srt(T &a){ sort(all(a)); return;}
template <typename T>
void srtr(T &a){ sort(a.rbegin(),a.rend()); return;}
using mint = modint998244353;
using vm=vector<mint>;
istream& operator>>(istream& is, mint& a) { long long x; is >> x; a = x; return is; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.val();}
void solve();
int op(int a, int b) {return a+b;}
int e(){return 0;}
int mapping(int a, int b) {return a+b;}
int composition(int a, int b) {return a+b;}
int id(){return 0;}
int main() {
int t = 1;
//cin >> t;
rep(i,t) solve();
return 0;
}
void solve() {
int n,m;
cin >> n >> m;
vi where(m);
rep(i,n) where[i] = i;
lazy_segtree<int,op,e, int, mapping, composition, id> t(m);
fenwick_tree<ll> ft(m);
vi a(n),l(n),r(n);
ll now = 0;
rep(i,n){
cin >> a[i] >> l[i] >> r[i];
l[i]--;
t.apply(l[i],r[i],1);
ft.add(i,a[i]);
}
rep(i,n){
now += (ll)(r[i]-l[i])*a[i]; //自分のレート
now -= (ll)t.prod(i,i+1)*a[i]; //相手から引かれる自分のレート
}
int q;
cin >> q;
rep(qi,q){
int x,y,u,v;
cin >> x >> y >> u >> v;
x--, y--, u--;
int pre = where[x];
where[x] = y;
now += (ll)(t.prod(pre,pre+1)-(l[x]<=pre && pre<r[x] ? 1 : 0))*a[x]; //相手から引かれていた自分のレート(自分自身は↓で対応)を加える
now -= (ll)(r[x]-l[x])*a[x]-ft.sum(l[x],r[x]); //自分のレートの和と引いていた相手のレートの和を引く
t.apply(l[x],r[x],-1); //自分が関与する範囲をリセット
l[x] = u;
r[x] = v;
t.apply(l[x],r[x],1); //自分が関与する範囲をセット
ft.add(pre,-a[x]); //相手から引く用のフェンウィックから引く
now -= (ll)ft.sum(l[x],r[x]); //lrの範囲にいる相手の点を引く
now += (ll)(r[x]-l[x])*a[x]; //lrの範囲の分自分を加える
now -= (t.prod(y,y+1))*a[x]; //移った先で他の人から自分のレートが引かれる
ft.add(y,a[x]); //加える
cout << now << endl;
}
return;
}