結果

問題 No.230 Splarraay スプラレェーイ
ユーザー t98slidert98slider
提出日時 2022-06-29 14:50:37
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 117 ms / 5,000 ms
コード長 971 bytes
コンパイル時間 3,419 ms
コンパイル使用メモリ 232,308 KB
実行使用メモリ 7,920 KB
最終ジャッジ日時 2023-08-14 18:00:53
合計ジャッジ時間 5,080 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 8 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 54 ms
5,520 KB
testcase_10 AC 59 ms
4,376 KB
testcase_11 AC 32 ms
4,528 KB
testcase_12 AC 54 ms
5,472 KB
testcase_13 AC 10 ms
4,380 KB
testcase_14 AC 62 ms
7,780 KB
testcase_15 AC 87 ms
7,788 KB
testcase_16 AC 100 ms
7,920 KB
testcase_17 AC 117 ms
7,780 KB
testcase_18 AC 81 ms
7,784 KB
testcase_19 AC 68 ms
7,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using ll = long long;

using S = array<int,3>;
S op(S l, S r){
    l[0] += r[0];
    l[1] += r[1];
    l[2] += r[2];
    return l;
}
S e(){return S({0,0,0});}
using F = int;
S mapping(F f, S x){
    if(f == -1)return x;
    int s = x[0] + x[1] + x[2];
    fill(x.begin(), x.end(), 0);
    x[f] = s;
    return x;
}
F composition(F f, F g){
    if(f == -1)return g;
    return f;
}
F id(){
    return -1;
}

int main(){
    int N, Q, x, l, r;
    cin >> N >> Q;
    long long A = 0, B = 0;
    atcoder::lazy_segtree<S,op,e,F,mapping,composition,id> seg(vector<S>(N, S({0, 0, 1})));
    while(Q--){
        cin >> x >> l >> r;
        r++;
        if(x)seg.apply(l,r,x-1);
        else{
            auto b = seg.prod(l,r);
            if(b[0] > b[1])A += b[0];
            if(b[1] > b[0])B += b[1];
        }
    }
    auto b = seg.all_prod();
    A += b[0], B += b[1];
    cout << A << " " << B << '\n';
}
0