結果
| 問題 |
No.2395 区間二次変換一点取得
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2023-07-28 23:03:21 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 61 ms / 2,000 ms |
| コード長 | 1,041 bytes |
| コンパイル時間 | 941 ms |
| コンパイル使用メモリ | 100,980 KB |
| 実行使用メモリ | 6,784 KB |
| 最終ジャッジ日時 | 2024-10-06 20:58:29 |
| 合計ジャッジ時間 | 3,288 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 20 |
ソースコード
#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;
}