結果

問題 No.2170 Left Addition Machine
ユーザー hotman78hotman78
提出日時 2022-12-22 10:03:22
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 923 bytes
コンパイル時間 2,163 ms
コンパイル使用メモリ 213,772 KB
実行使用メモリ 15,536 KB
最終ジャッジ日時 2024-04-29 05:27:16
合計ジャッジ時間 38,051 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 538 ms
15,360 KB
testcase_31 AC 522 ms
15,316 KB
testcase_32 AC 517 ms
15,536 KB
testcase_33 AC 532 ms
15,300 KB
testcase_34 AC 515 ms
15,360 KB
testcase_35 AC 539 ms
15,272 KB
testcase_36 AC 533 ms
15,360 KB
testcase_37 AC 510 ms
15,308 KB
testcase_38 AC 509 ms
15,476 KB
testcase_39 AC 367 ms
5,376 KB
testcase_40 AC 370 ms
5,376 KB
testcase_41 AC 374 ms
5,376 KB
testcase_42 AC 388 ms
5,376 KB
testcase_43 AC 366 ms
5,376 KB
testcase_44 AC 387 ms
5,376 KB
testcase_45 AC 366 ms
5,376 KB
testcase_46 AC 393 ms
5,376 KB
testcase_47 AC 383 ms
5,376 KB
testcase_48 AC 522 ms
15,360 KB
testcase_49 AC 536 ms
15,376 KB
testcase_50 AC 602 ms
15,292 KB
testcase_51 AC 541 ms
15,360 KB
testcase_52 AC 526 ms
15,268 KB
testcase_53 AC 536 ms
15,292 KB
testcase_54 AC 527 ms
15,288 KB
testcase_55 AC 543 ms
15,272 KB
testcase_56 AC 521 ms
15,360 KB
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
testcase_61 WA -
testcase_62 WA -
testcase_63 WA -
testcase_64 WA -
testcase_65 WA -
testcase_66 AC 124 ms
5,376 KB
testcase_67 AC 454 ms
15,308 KB
testcase_68 AC 510 ms
15,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/segtree.hpp>
#include<atcoder/modint.hpp>
using mint=atcoder::static_modint<998244353>;

using T=tuple<int,int,mint,mint>;
T f(T s,T t){
    if(get<1>(s)==-1)return t;
    if(get<1>(t)==-1)return s;
    if(get<1>(s)<get<0>(t)){
        return make_tuple(get<0>(s),get<1>(t),get<2>(s)*get<2>(t),get<3>(s)+get<3>(t)*get<2>(s));
    }else{
        return make_tuple(~get<0>(t),get<1>(t),get<2>(t),get<3>(t));
    }
}
T id(){
    return make_tuple(-1,-1,mint(1),mint(0));
}

int main(){
    int n,q;
    cin>>n>>q;
    vector<int>a(n);
    vector<T>v(n);
    for(int i=0;i<n;++i){
        cin>>a[i];
        v[i]=make_tuple(a[i],a[i],mint(2),mint(a[i]));
    }
    atcoder::segtree<T,f,id>seg(v);
    while(q--){
        int l,r;
        cin>>l>>r;
        l--;
        auto [x,y,z,w]=seg.prod(l,r);
        if(x<0)x=~x;
        cout<<((w+x)/2).val()<<endl;
    }
}
0