結果
問題 | No.2395 区間二次変換一点取得 |
ユーザー | abuka-benka |
提出日時 | 2023-07-28 23:03:21 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 66 ms / 2,000 ms |
コード長 | 1,041 bytes |
コンパイル時間 | 1,047 ms |
コンパイル使用メモリ | 99,612 KB |
実行使用メモリ | 6,784 KB |
最終ジャッジ日時 | 2024-04-16 07:00:17 |
合計ジャッジ時間 | 3,054 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | 2 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 | 2 ms
5,376 KB |
testcase_09 | AC | 2 ms
5,376 KB |
testcase_10 | AC | 2 ms
5,376 KB |
testcase_11 | AC | 3 ms
5,376 KB |
testcase_12 | AC | 7 ms
5,376 KB |
testcase_13 | AC | 66 ms
6,784 KB |
testcase_14 | AC | 65 ms
6,784 KB |
testcase_15 | AC | 65 ms
6,784 KB |
testcase_16 | AC | 65 ms
6,656 KB |
testcase_17 | AC | 65 ms
6,784 KB |
testcase_18 | AC | 56 ms
6,016 KB |
testcase_19 | AC | 55 ms
5,888 KB |
ソースコード
#include<iostream> #include<algorithm> #include<unordered_map> #include<queue> #include<vector> #include<cstring> #include<cstdio> #include<set> #include<ctime> #include<random> #include<string> #define dbg(x) cerr<<__LINE__<<':'<<#x<<" = "<<x<<'\n'; using namespace std; typedef long long ll; typedef long double ld; ll n,mod,Q; struct node{ ll x,y,z; }; node a[100009]; ll tr[100009]; void add(ll x,ll d){ for(int i=x;i<=n;i+=i&(-i))tr[i]+=d; } ll ask(ll x){ ll ans=0; for(int i=x;i;i-=i&(-i))ans+=tr[i]; return ans; } int main(){ #ifdef ABUKA freopen("abuka.in","r",stdin); freopen("abuka.out","w",stdout); #endif ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin>>n>>mod>>Q; a[0].x=a[0].y=a[0].z=1%mod; for(int i=1;i<=Q;i++){ a[i].x=(a[i-1].x+1)%mod; a[i].y=(3*a[i-1].y+2*a[i].x*a[i-1].z)%mod; a[i].z=3*a[i-1].z%mod; } ll l,m,r; for(int i=1;i<=Q;i++){ cin>>l>>m>>r; add(r+1,-1); add(l,1); ll tmp=ask(m); cout<<a[tmp].x<<' '<<a[tmp].y<<' '<<a[tmp].z<<'\n'; } return 0; }