結果

問題 No.259 セグメントフィッシング+
ユーザー t98slidert98slider
提出日時 2023-02-17 09:44:34
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 41 ms / 2,000 ms
コード長 794 bytes
コンパイル時間 3,220 ms
コンパイル使用メモリ 139,032 KB
実行使用メモリ 6,408 KB
最終ジャッジ日時 2023-09-26 11:02:50
合計ジャッジ時間 5,355 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 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,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,384 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 AC 37 ms
6,256 KB
testcase_09 AC 35 ms
6,164 KB
testcase_10 AC 34 ms
6,168 KB
testcase_11 AC 34 ms
6,148 KB
testcase_12 AC 33 ms
6,268 KB
testcase_13 AC 38 ms
6,148 KB
testcase_14 AC 38 ms
6,260 KB
testcase_15 AC 38 ms
6,168 KB
testcase_16 AC 39 ms
6,220 KB
testcase_17 AC 39 ms
6,188 KB
testcase_18 AC 39 ms
6,228 KB
testcase_19 AC 38 ms
6,224 KB
testcase_20 AC 39 ms
6,284 KB
testcase_21 AC 41 ms
6,340 KB
testcase_22 AC 39 ms
6,236 KB
testcase_23 AC 26 ms
4,380 KB
testcase_24 AC 36 ms
6,408 KB
testcase_25 AC 37 ms
6,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
using namespace std;
using namespace atcoder;
using namespace internal;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, Q, m, t, y, z;
    char x;
    cin >> N >> Q;
    m = 2 * N;
    fenwick_tree<long long> fw(m);
    auto f = [&](int l, int r){
        if(l <= r) return fw.sum(l, r);
        return fw.sum(0, r) + fw.sum(l, 2 * N);
    };
    while(Q--){
        cin >> x >> t >> y >> z;
        if(x != 'C'){
            if(x == 'L') y = m - 1 - y;
            fw.add(safe_mod(y - t, m), z);
        }else{
            int l1 = safe_mod(y - t, m);
            int r1 = safe_mod(z - t, m);
            int l2 = safe_mod(-z - t, m);
            int r2 = safe_mod(-y - t, m);
            cout << f(l1, r1) + f(l2, r2) << '\n';
        }
    }
}
0