結果

問題 No.259 セグメントフィッシング+
ユーザー t98slidert98slider
提出日時 2023-02-17 09:38:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 38 ms / 2,000 ms
コード長 891 bytes
コンパイル時間 2,870 ms
コンパイル使用メモリ 139,776 KB
実行使用メモリ 6,372 KB
最終ジャッジ日時 2023-09-26 10:59:20
合計ジャッジ時間 5,511 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,380 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 2 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 33 ms
6,136 KB
testcase_09 AC 33 ms
6,092 KB
testcase_10 AC 33 ms
6,260 KB
testcase_11 AC 34 ms
6,332 KB
testcase_12 AC 34 ms
6,208 KB
testcase_13 AC 37 ms
6,228 KB
testcase_14 AC 38 ms
6,204 KB
testcase_15 AC 37 ms
6,140 KB
testcase_16 AC 38 ms
6,204 KB
testcase_17 AC 38 ms
6,372 KB
testcase_18 AC 37 ms
6,196 KB
testcase_19 AC 36 ms
6,112 KB
testcase_20 AC 37 ms
6,140 KB
testcase_21 AC 36 ms
6,268 KB
testcase_22 AC 37 ms
6,160 KB
testcase_23 AC 25 ms
4,376 KB
testcase_24 AC 33 ms
6,260 KB
testcase_25 AC 32 ms
6,204 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/all>
using namespace std;
using ll = long long;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N, Q, r, t, y, z;
    cin >> N >> Q;
    atcoder::fenwick_tree<ll> fw(2 * N);
    char x;
    auto safe_mod = [&](int v, int mod){
        v %= mod;
        if(v < 0)v += mod;
        return v;
    };
    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 = 2 * N - 1 - y;
            fw.add(safe_mod(y - t, 2 * N), z);
        }else{
            int l1 = safe_mod(y - t, 2 * N);
            int r1 = safe_mod(z - t, 2 * N);
            int l2 = safe_mod(-z - t, 2 * N);
            int r2 = safe_mod(-y - t, 2 * N);
            cout << f(l1, r1) + f(l2, r2) << '\n';
        }
    }
}
0