結果
| 問題 | No.255 Splarrraaay スプラーレェーーイ | 
| コンテスト | |
| ユーザー |  houren | 
| 提出日時 | 2022-09-15 16:18:38 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,893 bytes | 
| コンパイル時間 | 2,310 ms | 
| コンパイル使用メモリ | 191,096 KB | 
| 実行使用メモリ | 169,116 KB | 
| 最終ジャッジ日時 | 2024-12-16 08:39:55 | 
| 合計ジャッジ時間 | 22,731 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 2 WA * 8 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/lazysegtree>
using namespace atcoder;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
const ll MOD = (ll)(1e18)+9;
struct S{
    ll val, siz;
};
using F = ll;
const F ID = 0;
S op(S a, S b){ return {a.val+b.val, a.siz+b.siz}; }
S e(){ return {0, 0}; }
S mapping(F f, S x){
    return (f>=0 ? (S){x.val + f*x.siz, x.siz} : (S){0, x.siz});
}
F composition(F f, F g){
    return (f>=0 ? f + g : -1);
}
F id(){ return ID; }
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,q;
    cin >> n >> q;
    set<ll> se;
    vector<ll> x(q), l(q), r(q);
    rep(i,q){
        cin >> x[i] >> l[i] >> r[i];
        x[i]--; r[i]++;
        se.insert(l[i]);
        se.insert(r[i]);
    }
    map<ll, ll> mp;
    vector<S> vec;
    ll now = 0, pre = -1;
    for(ll y:se){
        if(pre>=0) vec.push_back({0,y-pre});
        pre = y;
        mp[y] = now++;
    }
    vector<ll> ans(5,0);
    vector<lazy_segtree<S, op, e, F, mapping, composition, id>> seg(5,lazy_segtree<S, op, e, F, mapping, composition, id>(vec));
    rep(i,q){
        if(x[i]<0){
            ll t = -1, p = -1;
            rep(j,5){
                ll k = seg[j].prod(mp[l[i]], mp[r[i]]).val;
                if(chmax(p, k)) t = j;
                else if(p==k) t = -1;
            }
            if(t>=0) ans[t] = (ans[t] + p) % MOD;
        }else{
            rep(j,5) seg[j].apply(mp[l[i]], mp[r[i]], (x[i]==j)*2-1);
        }
    }
    rep(i,5) cout << (ans[i] + seg[i].all_prod().val) % MOD << " ";
    cout << '\n';
    return 0;
}
            
            
            
        