题解
代码
| #include<bits/stdc++.h> |
| #define int long long |
| #define N (1000010) |
| #define I i |
| #define J j |
| #define raed read |
| #define reaD read |
| #define reAD read |
| #define rEAD read |
| #define READ read |
| #define REAd read |
| #define REad read |
| #define Read read |
| #define Reda read |
| #define redA read |
| #define reDA read |
| #define redA read |
| #define itn signed |
| #define Itn signed |
| #define ITN signed |
| #define Int signed |
| #define INT signed |
| #define foR for |
| #define fot for |
| #define foT for |
| #define sort stable_sort |
| using namespace std; |
| namespace IO |
| { |
| #define ll long long |
| const int MAX=1<<24; |
| char buf[MAX],*p1=buf,*p2=buf; |
| char obuf[MAX],*o=obuf; |
| #define gc()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<24,stdin),p1==p2)?EOF:*p1++) |
| |
| |
| inline int read() |
| { |
| int x=0;bool f=1; |
| char c=gc(); |
| for(;c<48||c>57;c=gc())if(c=='-')f=0; |
| for(;c>=48&&c<=57;c=gc())x=(x<<3)+(x<<1)+(c^48); |
| return f?x:~x+1; |
| } |
| void print(ll x){if(x>9)print(x/10);*o++=(x%10)+'0';} |
| void pit(ll x){if(x<0)*o++='-',x=~x+1;print(x);} |
| void write(ll x,char ed){pit(x);*o++=ed;} |
| void flush(){fwrite(obuf,o-obuf,1,stdout);} |
| #undef ll |
| } |
| using IO::read;using IO::write;using IO::flush;using std::complex; |
| inline int min(int x,int y){return y&((y-x)>>31)|x&(~(y-x)>>31);} |
| inline int max(int x,int y){return x&((y-x)>>31)|y&(~(y-x)>>31);} |
| inline void swap(int &x,int &y){int tmp=x;x=y;y=tmp;} |
| long long n,m; |
| void init_set() |
| { |
| #ifndef ONLINE_JUDGE |
| freopen("in.txt","r",stdin); |
| freopen("out.txt","w",stdout); |
| #endif |
| ios::sync_with_stdio(0); |
| cin.tie(0),cout.tie(0); |
| } |
| int tot,t; |
| bool honkai_star_rail[20]; |
| int furina[10010],fucaros[1000010]; |
| int fontaine[1000010]; |
| int panzer; |
| signed main() |
| { |
| init_set(); |
| n=read(); |
| for(int i(1);i<=(n<<2);++i)fontaine[i]=read(); |
| sort(fontaine+1,fontaine+1+(n<<2)); |
| for(int i(1);i<=n;++i) |
| tot+=fontaine[(n<<2)-(i<<1)+2]*fontaine[(n<<2)-(i<<1)+1], |
| tot-=fontaine[i]*fontaine[(n<<1)-i+1]; |
| write(tot,' '); |
| flush(); |
| return 0; |
| } |
题解
代码
题解
代码
题解
代码
| #include<bits/stdc++.h> |
| #define int long long |
| #define N (1000010) |
| #define ls (p<<1) |
| #define rs (p<<1|1) |
| #define I i |
| #define J j |
| #define raed read |
| #define reaD read |
| #define reAD read |
| #define rEAD read |
| #define READ read |
| #define REAd read |
| #define REad read |
| #define Read read |
| #define Reda read |
| #define redA read |
| #define reDA read |
| #define redA read |
| #define itn signed |
| #define Itn signed |
| #define ITN signed |
| #define Int signed |
| #define INT signed |
| #define foR for |
| #define fot for |
| #define foT for |
| #define sort stable_sort |
| using namespace std; |
| namespace IO |
| { |
| #define ll long long |
| const int MAX=1<<24; |
| char buf[MAX],*p1=buf,*p2=buf; |
| char obuf[MAX],*o=obuf; |
| #define gc()(p1==p2&&(p2=(p1=buf)\ |
| +fread(buf,1,1<<24,stdin),p1==p2)?EOF:*p1++) |
| |
| |
| inline int read() |
| { |
| int x=0;bool f=1; |
| char c=gc(); |
| for(;c<48||c>57;c=gc())if(c=='-')f=0; |
| for(;c>=48&&c<=57;c=gc())x=(x<<3)+(x<<1)+(c^48); |
| return f?x:~x+1; |
| } |
| void print(ll x){if(x>9)print(x/10);*o++=(x%10)+'0';} |
| void pit(ll x){if(x<0)*o++='-',x=~x+1;print(x);} |
| void write(ll x,char ed){pit(x);*o++=ed;} |
| void flush(){fwrite(obuf,o-obuf,1,stdout);} |
| #undef ll |
| } |
| using IO::read;using IO::write;using IO::flush;using std::complex; |
| inline int min(int x,int y){return y&((y-x)>>31)|x&(~(y-x)>>31);} |
| inline int max(int x,int y){return x&((y-x)>>31)|y&(~(y-x)>>31);} |
| inline void swap(int &x,int &y){x^=y^=x^=y;} |
| long long n,m; |
| void init_set() |
| { |
| #ifndef ONLINE_JUDGE |
| freopen("in.txt","r",stdin); |
| freopen("out.txt","w",stdout); |
| #endif |
| ios::sync_with_stdio(0); |
| cin.tie(0),cout.tie(0); |
| } |
| int tot,x,y; |
| struct aa |
| { |
| int nahida,sumeru,panzer; |
| |
| struct lazytag |
| { |
| int furina,Paimon,fucaros; |
| |
| |
| inline lazytag() |
| {furina=-1,Paimon=fucaros=0;} |
| |
| inline lazytag(int furina):furina(furina) |
| {if(furina==-1)Paimon=1;} |
| }tag; |
| }t[4000010]; |
| bool tp2=true; |
| int disco; |
| int fontaine[1000010]; |
| int honkai_star_rail; |
| int kamisato_ayaka; |
| int Cyberpunk_2077[1000010]; |
| int Soviet[1000010]; |
| int honkai[1000010]; |
| inline void pushup(int p) |
| { |
| t[p].nahida=min(t[ls].nahida,t[rs].nahida); |
| t[p].sumeru=t[ls].sumeru,t[rs].sumeru; |
| t[p].panzer=t[ls].panzer,t[rs].panzer; |
| } |
| void build(int p=1,int l=0,int r=m) |
| { |
| if(l==r){t[p].sumeru=t[p].nahida=Soviet[l];return;} |
| int mid(l+r>>1); |
| build(ls,l,mid),build(rs,mid+1,r); |
| pushup(p); |
| } |
| inline void down(aa::lazytag tag,int p,int l,int r) |
| { |
| t[p].panzer+=t[p].sumeru*tag.Paimon+tag.fucaros; |
| |
| if(~tag.furina) |
| { |
| if(~t[p].tag.furina) |
| t[p].tag.fucaros+=t[p].tag.furina*tag.Paimon+tag.fucaros; |
| else |
| t[p].tag.Paimon+=tag.Paimon, |
| t[p].tag.fucaros+=tag.fucaros; |
| t[p].sumeru=t[p].nahida=tag.furina; |
| t[p].tag.furina=tag.furina; |
| } |
| else |
| { |
| |
| if(~t[p].tag.furina)t[p].tag.fucaros+=t[p].tag.furina*tag.Paimon; |
| |
| else t[p].tag.Paimon+=tag.Paimon; |
| } |
| } |
| inline void pushdown(int p,int l,int r) |
| { |
| int mid(l+r>>1); |
| down(t[p].tag,ls,l,mid),down(t[p].tag,rs,mid+1,r); |
| t[p].tag=aa::lazytag(); |
| } |
| void update(int p,int ql,int qr,int l,int r,int v) |
| { |
| if(qr<l||r<ql)return; |
| if(ql<=l&&r<=qr) |
| {down(aa::lazytag(v),p,l,r);return;} |
| pushdown(p,l,r); |
| int mid(l+r>>1); |
| update(ls,ql,qr,l,mid,v),update(rs,ql,qr,mid+1,r,v); |
| pushup(p); |
| } |
| inline void PaimonDown() |
| {down(aa::lazytag(-1),1,1,m);} |
| int search(int p,int ql,int qr,int l,int r,int v) |
| { |
| if(qr<l||r<ql||v<=t[p].nahida)return -1; |
| |
| if(l==r&&ql<=l&&r<=qr)return l; |
| int mid(l+r>>1); |
| int res(search(rs,ql,qr,mid+1,r,v)); |
| return ~res?res:search(ls,ql,qr,l,mid,v); |
| } |
| void SetAns(int p=1,int l=0,int r=m) |
| { |
| if(l==r){honkai[l]=t[p].panzer;return;} |
| int mid(l+r>>1); |
| pushdown(p,l,r),SetAns(ls,l,mid),SetAns(rs,mid+1,r); |
| } |
| signed main() |
| { |
| init_set(); |
| n=read();m=read(); |
| for(signed i(1);i<=n;++i) |
| { |
| fontaine[i]=read(); |
| if(!fontaine[i]) |
| { |
| kamisato_ayaka+=(i-honkai_star_rail-1)*(i-honkai_star_rail)>>1; |
| honkai_star_rail=i; |
| } |
| if(fontaine[i]!=i%m)tp2=false; |
| } |
| if(tp2) |
| { |
| x=read(),y=read(); |
| disco=n*(n+1)>>1; |
| for(int i(x);i<=y;++i) |
| { |
| if(i==0)write(((n/m)*((m-1)*m)>>1)+(((n%m))*(n%m+1)>>1),' '), |
| disco-=((n/m)*((m-1)*m)>>1)+(((n%m))*(n%m+1)>>1); |
| else if(i==m) |
| write(disco,' '); |
| else write(((n-i+1)/m)*(m-i),' '),disco-=((n-i+1)/m)*(m-i); |
| } |
| flush();exit(0); |
| } |
| kamisato_ayaka+=(n-honkai_star_rail)*(n+1-honkai_star_rail)>>1; |
| for(int i(0);i<=m;++i) |
| Soviet[i]=n+1; |
| for(int i(n);i;--i) |
| Cyberpunk_2077[i]=Soviet[fontaine[i]], |
| |
| Soviet[fontaine[i]]=i; |
| |
| |
| |
| for(int i(1);i<m;++i) |
| Soviet[i]=max(Soviet[i],Soviet[i-1]); |
| |
| build(1,0,m); |
| for(int i(1);i<=n;++i) |
| { |
| PaimonDown(); |
| int browser(search(1,fontaine[i],m,0,m,Cyberpunk_2077[i])); |
| |
| if(~browser)update(1,fontaine[i],browser,0,m,Cyberpunk_2077[i]); |
| } |
| SetAns(1,0,m); |
| x=read(),y=read(); |
| if(!x)write(kamisato_ayaka,' '),x=1; |
| for(int i(x);i<=y;++i) |
| write(honkai[i]-honkai[i-1],' '); |
| flush(); |
| return 0; |
| } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】