結果
問題 | No.259 セグメントフィッシング+ |
ユーザー | 沙耶花 |
提出日時 | 2022-03-25 16:58:26 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 131 ms / 2,000 ms |
コード長 | 1,302 bytes |
コンパイル時間 | 4,051 ms |
コンパイル使用メモリ | 256,616 KB |
実行使用メモリ | 6,656 KB |
最終ジャッジ日時 | 2024-04-22 02:45:16 |
合計ジャッジ時間 | 8,350 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,248 KB |
testcase_01 | AC | 2 ms
5,376 KB |
testcase_02 | AC | 2 ms
5,376 KB |
testcase_03 | AC | 2 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 2 ms
5,376 KB |
testcase_06 | AC | 2 ms
5,376 KB |
testcase_07 | AC | 2 ms
5,376 KB |
testcase_08 | AC | 114 ms
6,528 KB |
testcase_09 | AC | 113 ms
6,656 KB |
testcase_10 | AC | 110 ms
6,528 KB |
testcase_11 | AC | 115 ms
6,528 KB |
testcase_12 | AC | 113 ms
6,656 KB |
testcase_13 | AC | 125 ms
6,656 KB |
testcase_14 | AC | 127 ms
6,656 KB |
testcase_15 | AC | 126 ms
6,528 KB |
testcase_16 | AC | 121 ms
6,656 KB |
testcase_17 | AC | 124 ms
6,656 KB |
testcase_18 | AC | 131 ms
6,528 KB |
testcase_19 | AC | 124 ms
6,528 KB |
testcase_20 | AC | 126 ms
6,656 KB |
testcase_21 | AC | 125 ms
6,400 KB |
testcase_22 | AC | 125 ms
6,400 KB |
testcase_23 | AC | 79 ms
5,376 KB |
testcase_24 | AC | 95 ms
6,400 KB |
testcase_25 | AC | 96 ms
6,400 KB |
ソースコード
#include <stdio.h> #include <bits/stdc++.h> #include <atcoder/all> using namespace atcoder; using mint = modint998244353; using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) #define Inf 1000000001 int main(){ int n,q; cin>>n>>q; n--; fenwick_tree<long long> F(2*(n+1)); rep(i,q){ char c; cin>>c; if(c=='L'){ long long t,y,z; cin>>t>>y>>z; long long temp = n+1; temp += n-y; temp -= t; temp %= n*2+2; if(temp<0)temp += n*2+2; F.add(temp,z); } else if(c=='R'){ long long t,y,z; cin>>t>>y>>z; long long temp = y; temp -= t; temp %= n*2+2; if(temp<0)temp += n*2+2; F.add(temp,z); } else{ long long ans = 0; long long t,y,z; cin>>t>>y>>z; long long l = y; long long r = z; l -= t; r -= t; l %= 2*n+2; l+=n*2+2; l %= 2*n+2; r %= 2*n+2; r+=n*2+2; r %= 2*n+2; if(l<=r)ans += F.sum(l,r); else{ ans += F.sum(0,r); ans += F.sum(l,n*2+2); } l = n+1+(n-z); r = n+1+(n-y);//z; l++,r++; l -= t; r -= t; l %= 2*n+2; l+=n*2+2; l %= 2*n+2; r %= 2*n+2; r+=n*2+2; r %= 2*n+2; //cout<<l<<','<<r<<endl; if(l<=r)ans += F.sum(l,r); else{ ans += F.sum(0,r); ans += F.sum(l,n*2+2); } cout<<ans<<endl; } } return 0; }