UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#213153#584. t3nullptr_qwq1001014ms7424kbC++116.0kb2024-11-09 21:32:212024-11-09 23:21:57

answer

// 私は猫です

#include<bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mkp make_pair
#define fi first
#define se second
#define inf 1000000000
#define infll 1000000000000000000ll
#define pii pair<int,int>
#define rep(i,a,b,c) for(int i=(a);i<=(b);i+=(c))
#define per(i,a,b,c) for(int i=(a);i>=(b);i-=(c))
#define F(i,a,b) for(int i=a,i##end=b;i<=i##end;i++)
#define dF(i,a,b) for(int i=a,i##end=b;i>=i##end;i--)
#define cmh(sjy) while(sjy--)
#define lowbit(x) (x&(-x))
#define HH printf("\n")
#define eb emplace_back
#define poly vector<int>
#define SZ(x) ((int)x.size())
using namespace std;
ll read(){
	ll x=0,f=1;char c=getchar();
	while(c<'0'||c>'9'){if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return x*f;
}
namespace Fastio{struct Reader{template<typename T>Reader&operator>>(T&x){x=0;short f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9')x=(x<<3)+(x<<1)+(c^48),c=getchar();x*=f;return*this;}Reader&operator>>(double&x){x=0;double t=0;short f=1,s=0;char c=getchar();while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else{x*=f;return*this;}while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}Reader&operator>>(long double&x){x=0;long double t=0;short f=1,s=0;char c=getchar();while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else{x*=f;return*this;}while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}Reader&operator>>(__float128&x){x=0;__float128 t=0;short f=1,s=0;char c=getchar();while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else{x*=f;return*this;}while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}Reader&operator>>(char&c){c=getchar();while(c==' '||c=='\n'||c=='\r')c=getchar();return*this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c==' '||c=='\n'||c=='\r')c=getchar();while(c!=' '&&c!='\n'&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}Reader&operator>>(string&str){str.clear();char c=getchar();while(c==' '||c=='\n'||c=='\r')c=getchar();while(c!=' '&&c!='\n'&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';struct Writer{const int Setprecision=6;typedef int mxdouble;template<typename T>Writer&operator<<(T x){if(x==0){putchar('0');return*this;}if(x<0)putchar('-'),x=-x;static short sta[40];short top=0;while(x>0)sta[++top]=x%10,x/=10;while(top>0)putchar(sta[top]+'0'),top--;return*this;}Writer&operator<<(double x){if(x<0)putchar('-'),x=-x;mxdouble _=x;x-=(double)_;static short sta[40];short top=0;while(_>0)sta[++top]=_%10,_/=10;if(top==0)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_>0)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;return*this;}Writer&operator<<(long double x){if(x<0)putchar('-'),x=-x;mxdouble _=x;x-=(long double)_;static short sta[40];short top=0;while(_>0)sta[++top]=_%10,_/=10;if(top==0)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_>0)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;return*this;}Writer&operator<<(__float128 x){if(x<0)putchar('-'),x=-x;mxdouble _=x;x-=(__float128)_;static short sta[40];short top=0;while(_>0)sta[++top]=_%10,_/=10;if(top==0)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;putchar('.');for(int i=0;i<Setprecision;i++)x*=10;_=x;while(_>0)sta[++top]=_%10,_/=10;for(int i=0;i<Setprecision-top;i++)putchar('0');while(top>0)putchar(sta[top]+'0'),top--;return*this;}Writer&operator<<(char c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}Writer&operator<<(string str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}using namespace Fastio;
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
template<typename T>inline void chkmax(T &x,const T &y){ x=std::max(x,y); }
template<typename T>inline void chkmin(T &x,const T &y){ x=std::min(x,y); }
const int mod=1e9+7,maxn=500005;
inline int qpow(int x,ll y){
	int rt=1;
	for(;y;y>>=1,x=1ll*x*x%mod) if(y&1) rt=1ll*rt*x%mod;
	return rt;
}
inline void inc(int &x,const int y){ x=(x+y>=mod)?(x+y-mod):(x+y); }
inline void dec(int &x,const int y){ x=(x>=y)?(x-y):(x+mod-y); }
inline void mul(int &x,const int y){ x=1ll*x*y%mod; }
inline int add(const int x,const int y){ return (x+y>=mod)?(x+y-mod):(x+y); }
inline int sub(const int x,const int y){ return (x>=y)?(x-y):(x+mod-y); }
inline int prod(const int x,const int y){ return 1ll*x*y%mod; }
int a[maxn],n,zsy;
struct node{
	int l,r;
	mutable int v;
	bool operator<(const node &rhs)const{ return l<rhs.l; }
};
set<node>s;
auto split(int pos){
	auto it=s.lower_bound({pos,0,0});
	if(it!=s.end()&&(it->l)==pos)return it;
	--it;
	int l=it->l,r=it->r,v=it->v;
	s.erase(it),s.insert({l,pos-1,v});
	return s.insert({pos,r,v}).fi;
}
void assign(int l,int r,int val){
	auto R=split(r+1),L=split(l);
	s.erase(L,R),s.insert({l,r,val});
}
void add(int l,int r,int val){
	auto R=split(r+1),L=split(l);
	for(;L!=R;++L)L->v+=val;
}
int query(int l,int r,int k){
	auto R=split(r+1),L=split(l);
	int res=0;
	for(;L!=R;++L)inc(res,1ll*((L->r)-(L->l)+1)*qpow(L->v,k)%mod);
	return res;
}
void solve(){
	cin>>n>>zsy;
	F(i,1,n){
		int x; cin>>x;
		s.insert({i,i,x});
	}
	F(_,1,zsy){
		int op,l,r,x;
		cin>>op>>l>>r>>x;
		if(op==1)add(l,r,x);
		else if(op==2)assign(l,r,x);
		else cout<<query(l,r,x)<<endl;
	}
}
signed main(){
	int zsy=1;
	F(____,1,zsy)solve();
}

详细

小提示:点击横条可展开更详细的信息

Test #1:

score: 10
Accepted
time: 1ms
memory: 1200kb

input:

458 823
14431 9895 11970 15308 2575 20181 709 27999 12992 18884 11061 16281 5044 28990 25092 28337 3...

output:

806084096
117884357
581509507
903754571
381316325
789203673
312340523
659242359
741787988
89040104
4...

result:

ok 261 lines

Test #2:

score: 10
Accepted
time: 0ms
memory: 1204kb

input:

481 526
8409 14498 18636 10027 24362 32458 17986 17730 11956 19192 2193 1034 29317 19284 16210 26242...

output:

867105097
717265913
288311190
320452351
133
498037408
473281413
216488030
182572597
611630662
471106...

result:

ok 179 lines

Test #3:

score: 10
Accepted
time: 121ms
memory: 7424kb

input:

100000 100000
15247 4194 9619 4532 22058 2667 21549 16652 25327 12018 13395 11426 7243 11714 22904 2...

output:

54433
544457741
352487648
82525935
532381851
235929450
38218
30045720
19138
459644406
33559
30953524...

result:

ok 33327 lines

Test #4:

score: 10
Accepted
time: 115ms
memory: 7420kb

input:

100000 100000
6264 26207 28424 24165 4852 20798 5803 18679 24588 12238 25786 28622 19900 101 25922 2...

output:

18923
13111195
41716
34447
32091
80654
731180277
9973
523560023
19797
159789457
695071461
3136
95363...

result:

ok 33328 lines

Test #5:

score: 10
Accepted
time: 118ms
memory: 7420kb

input:

100000 100000
15043 9299 7163 25384 24996 3803 24356 12466 22073 12987 8931 14997 3951 32704 23076 8...

output:

754347097
6296
588341566
325967942
180064833
683
831351544
63953
57030
17635
175222109
5280
57193
32...

result:

ok 33349 lines

Test #6:

score: 10
Accepted
time: 126ms
memory: 7420kb

input:

100000 100000
14736 16956 19864 23894 29403 5507 12182 6188 17192 14440 18618 3970 15396 15037 23334...

output:

17008
73008
935797904
16519312
15383
25232
236856418
75334
25854
46510
797344028
517157465
595936107...

result:

ok 33304 lines

Test #7:

score: 10
Accepted
time: 82ms
memory: 4296kb

input:

50000 50000
17799 29763 25337 21321 1391 31852 27418 28753 18524 14044 15976 18893 12274 22834 11348...

output:

19498
473297203
695948777
299749756
50630760
692747746
369627246
181903142
328502296
939823794
69850...

result:

ok 16802 lines

Test #8:

score: 10
Accepted
time: 95ms
memory: 4296kb

input:

50000 50000
10654 14956 14287 25326 8102 30579 11682 23553 272 22672 14460 30241 13026 12738 4912 72...

output:

717018991
140916081
273712387
602991268
878512570
665908548
10388
4939
283493752
435656498
657720400...

result:

ok 16814 lines

Test #9:

score: 10
Accepted
time: 161ms
memory: 6800kb

input:

90000 90000
29538 28214 24706 30393 27759 9002 13458 10243 15713 14881 10630 5593 7942 24578 29370 1...

output:

738835738
738703020
3888
402391875
37270
872563699
273399892
807398793
365897262
255303782
93280847
...

result:

ok 29904 lines

Test #10:

score: 10
Accepted
time: 195ms
memory: 7420kb

input:

100000 100000
23515 49 31372 25112 16779 21279 30735 32743 14678 15189 1763 23114 32215 14873 20487 ...

output:

576735050
562509678
553431297
662173102
515338212
478400370
879269281
500659410
483381164
1679282
16...

result:

ok 33309 lines