結果

問題 No.230 Splarraay スプラレェーイ
ユーザー hourenhouren
提出日時 2022-09-14 23:11:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 126 ms / 5,000 ms
コード長 1,470 bytes
コンパイル時間 1,791 ms
コンパイル使用メモリ 170,932 KB
実行使用メモリ 14,928 KB
最終ジャッジ日時 2023-08-21 20:48:22
合計ジャッジ時間 4,122 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 7 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 56 ms
8,832 KB
testcase_10 AC 53 ms
4,380 KB
testcase_11 AC 33 ms
6,188 KB
testcase_12 AC 58 ms
8,824 KB
testcase_13 AC 10 ms
4,380 KB
testcase_14 AC 50 ms
14,760 KB
testcase_15 AC 92 ms
14,748 KB
testcase_16 AC 101 ms
14,708 KB
testcase_17 AC 126 ms
14,860 KB
testcase_18 AC 78 ms
14,928 KB
testcase_19 AC 77 ms
14,836 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;}
struct S{
    ll val;
    int siz;
};
using F = ll;
const F ID = 8e18;
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){
    if(f != ID) x.val = f*x.siz;
    return x;
}
F composition(F f, F g){ return (f == ID ? g : f); }
F id(){ return ID; }
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    vector<S> vec(n,{0,1});
    lazy_segtree<S, op, e, F, mapping, composition, id> sega(vec), segb(vec);
    ll a = 0, b = 0;
    rep(i,q){
        int x, l, r;
        cin >> x >> l >> r;
        r++;
        if(x==0){
            ll p = sega.prod(l, r).val, q = segb.prod(l, r).val;
            if(p>q) a += p;
            else if(p<q) b += q;
        }else if(x==1){
            sega.apply(l,r,1);
            segb.apply(l,r,0);
        }else{
            sega.apply(l,r,0);
            segb.apply(l,r,1);
        }
    }
    cout << a+sega.all_prod().val << " " << b+segb.all_prod().val << '\n';
    return 0;
}
0