记录编号 |
253100 |
评测结果 |
AAAAAAAAAA |
题目名称 |
魔法传输 |
最终得分 |
100 |
用户昵称 |
咸鱼二号 |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.428 s |
提交时间 |
2016-04-21 19:03:29 |
内存使用 |
12.52 MiB |
显示代码纯文本
- #include<iostream>
- #include<cstring>
- #include<cstdio>
- #include<string>
- #include<algorithm>
- #include<cmath>
- #include<utility>
- #include<cstdlib>
- #include<iomanip> //cout<<setiosflags(ios::fixed)<<setprecision(2);
- #include<ctime> //double a=(double)clock(); cout<<a<<endl;
- #include<vector>
- #include<queue>
- using namespace std;
- const int maxn=100010;
- inline int read(){
- int x=0,ff=1;char ch=getchar();
- while(ch>'9'||ch<'0'){if(ch=='-')ff=-1; ch=getchar();}
- while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
- return ff*x;
- }
- char ch;
- int N,M,t1,t2;
- struct seg{
- long long k,b,tagk,tagb;
- }T[maxn<<2];
- inline void push_down(int root){
- if(T[root].tagk){
- T[root<<1].k+=T[root].tagk;
- T[root<<1].tagk+=T[root].tagk;
- T[root<<1|1].k+=T[root].tagk;
- T[root<<1|1].tagk+=T[root].tagk;
- T[root].tagk=0;
- }
- if(T[root].tagb){
- T[root<<1].b+=T[root].tagb;
- T[root<<1].tagb+=T[root].tagb;
- T[root<<1|1].b+=T[root].tagb;
- T[root<<1|1].tagb+=T[root].tagb;
- T[root].tagb=0;
- }
- }
- void update(int L,int R,int root,int l,int r){
- if(l<=L&&r>=R){
- T[root].k++;
- T[root].tagk++;
- T[root].b+=-l+1;
- T[root].tagb+=-l+1;
- return;
- }
- push_down(root);
- int mid=(L+R)>>1;
- if(l<=mid)
- update(L,mid,root<<1,l,r);
- if(r>mid)
- update(mid+1,R,root<<1|1,l,r);
- }
- long long ansk,ansb;
- void query(int L,int R,int root,int point){
- if(L==R){
- ansk=T[root].k;
- ansb=T[root].b;
- return;
- }
- push_down(root);
- int mid=(L+R)>>1;
- if(point<=mid)
- query(L,mid,root<<1,point);
- else
- query(mid+1,R,root<<1|1,point);
- }
- int main(){
- freopen("magics.in","r",stdin);
- freopen("magics.out","w",stdout);
- N=read(),M=read();
- while(M--){
- ch=getchar();
- while(ch!='C'&&ch!='Q')
- ch=getchar();
- if(ch=='C'){
- t1=read(),t2=read();
- update(1,N,1,t1,t2);
- }
- else{
- t1=read();
- query(1,N,1,t1);
- printf("%lld\n",(ansk*t1+ansb)%1000000007);
- }
- }
- return 0;
- }