QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#418583#4918. 染色dengtingyu0 0ms0kbC++145.8kb2024-05-23 14:36:522024-05-23 14:36:53

Judging History

你现在查看的是最新测评结果

  • [2024-05-23 14:36:53]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:0kb
  • [2024-05-23 14:36:52]
  • 提交

answer

#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
using namespace std;
#define ll int
#define ull unsigned long long
#define T pair<ll,ll>
#define fi first
#define se second
#define mk make_pair
const ll N=3e5+10,inf=1e9+10;
ll n,m;
ull val[N<<2],tag[N<<2],tgmi[N<<2];
ll len[N<<2];
T mi[N<<2];
struct sd{
    priority_queue<ll,vector<ll>,greater<ll> >u,v;
    inline void push(ll x){u.push(x);return ;}
    inline void pop(ll x){v.push(x);return ;}
    inline ll gt(){while(!v.empty()&&u.top()==v.top())u.pop(),v.pop();if(u.empty())return inf;return u.top();}
}hs[N<<2];
inline void push(ll o,ull x){tag[o]+=x;val[o]+=x*len[o];return ;}
inline void pushm(ll o,ull x,ll y){if(y>=hs[o].gt())push(o,x);else if(y>=mi[o].fi)tgmi[o]+=x,val[o]+=x*mi[o].se;return ;}
inline void pushdown(ll o){
    if(tag[o])push(o<<1,tag[o]),push(o<<1|1,tag[o]),tag[o]=0;
    if(tgmi[o])pushm(o<<1,tgmi[o],mi[o].fi),pushm(o<<1|1,tgmi[o],mi[o].fi),tgmi[o]=0;
    return ;
}
inline T heb(T x,T y){if(x.fi==y.fi)return mk(x.fi,x.se+y.se);return min(x,y);}
inline void pushup(ll o){
    mi[o]=heb(mi[o<<1],mi[o<<1|1]);
    if(mi[o].fi>=hs[o].gt())mi[o]=mk(hs[o].gt(),len[o]);
    val[o]=val[o<<1]+val[o<<1|1];
    return ;
}
inline void build(ll o,ll l,ll r){
    len[o]=r-l+1;if(l==r){mi[o]=mk(inf,1);return ;}
    ll mid=(l+r)>>1;
    build(o<<1,l,mid);
    build(o<<1|1,mid+1,r);
    pushup(o);return ;
}
inline void update(ll o,ll l,ll r,ll x,ll y,ll z,ll tp){
    if(l==r){if(tp)hs[o].push(z);else hs[o].pop(z);mi[o]=mk(hs[o].gt(),1);return ;}
    if(x<=l&&r<=y){
        pushdown(o);
        if(tp)hs[o].push(z);else hs[o].pop(z);
        pushup(o);
        return ;
    }ll mid=(l+r)>>1;pushdown(o);
    if(mid>=x)update(o<<1,l,mid,x,y,z,tp);
    if(mid<y)update(o<<1|1,mid+1,r,x,y,z,tp);
    pushup(o);return ;
}
inline void add(ll o,ll l,ll r,ll x,ll y,ull z){
    if(x<=l&&r<=y){push(o,z);return ;}
    ll mid=(l+r)>>1;pushdown(o);
    if(mid>=x)add(o<<1,l,mid,x,y,z);
    if(mid<y)add(o<<1|1,mid+1,r,x,y,z);
    pushup(o);return ;
}
inline void upd(ll o,ll l,ll r,ll x,ll y,ll p,ull z){
    if(hs[o].gt()<=p){add(o,l,r,x,y,z);return ;}
    if(x<=l&&r<=y){pushm(o,z,p);return ;}
    ll mid=(l+r)>>1;pushdown(o);
    if(mid>=x)upd(o<<1,l,mid,x,y,p,z);
    if(mid<y)upd(o<<1|1,mid+1,r,x,y,p,z);
    pushup(o);return ;
}
inline ull ask(ll o,ll l,ll r,ll x,ll y){
    if(x<=l&&r<=y)return val[o];
    ll mid=(l+r)>>1;ull an=0;pushdown(o);
    if(mid>=x)an+=ask(o<<1,l,mid,x,y);
    if(mid<y)an+=ask(o<<1|1,mid+1,r,x,y);
    return an;
}
inline ll query(ll o,ll l,ll r,ll x,ll y){
    if(x<=l&&r<=y)return mi[o].fi;
    ll mid=(l+r)>>1,an=hs[o].gt();pushdown(o);
    if(mid>=x)an=min(an,query(o<<1,l,mid,x,y));
    if(mid<y)an=min(an,query(o<<1|1,mid+1,r,x,y));
    return an;
}
set< T >s[N];
inline void ins(ll o,ll l,ll r){s[o].insert(mk(l,r));update(1,1,n,l,r,o,1);return ;}
inline void era(ll o,ll l,ll r){s[o].erase(mk(l,r));update(1,1,n,l,r,o,0);return ;}
inline void split(ll o,ll x){
    auto p=s[o].lower_bound(mk(x,inf));if(p==s[o].begin())return ;
    p--;if((*p).se<x||(*p).fi==x)return ;
    ll u=(*p).fi,v=(*p).se;
    era(o,u,v);
    ins(o,u,x-1);ins(o,x,v);
    return ;
}
inline void out(ll o,ll l,ll r){
    split(o,l);split(o,r+1);
    for(auto p=s[o].lower_bound(mk(l,0));p!=s[o].end()&&(*p).fi<=r;){
        ll u=(*p).fi,v=(*p).se;p++;
        era(o,u,v);
    }return ;
}
int main(){
    freopen("test1.in","r",stdin);
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    cin>>n>>m;build(1,1,n);
    for(int i=1;i<=m+1;i++)ins(i,1,n);
    for(int i=1;i<=m;i++){
        ll op,l,r;ull x;cin>>op>>l>>r;if(op!=4)cin>>x;
        if(op==1){
            out(x,l,r);   
        }if(op==2){
            out(x,l,r);ins(x,l,r);
        }if(op==3){
            ll tem=query(1,1,n,l,r);
            upd(1,1,n,l,r,tem,x);
        }if(op==4)cout<<ask(1,1,n,l,r)<<'\n';
    }return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Runtime Error

Test #1:

score: 0
Runtime Error

input:

1000 1000
3 722 914 2141556875752121755
3 323 347 6433743606947304931
2 142 206 439
2 117 840 195
2 127 502 56
3 168 707 15142638115094015116
4 190 257
2 88 976 475
1 319 867 351
1 682 889 409
2 406 446 196
3 28 35 4899387534800369959
2 291 546 150
1 528 617 128
1 58 122 251
2 381 400 276
4 510 958
...

output:


result:


Subtask #2:

score: 0
Runtime Error

Test #11:

score: 0
Runtime Error

input:

300000 300000
1 237576 237663 1
3 16150 16208 9270412155482010138
2 175648 175692 1
4 190836 190849
4 199010 199097
1 73976 298801 1
3 89902 89939 6418828085116455990
3 55415 55461 12238963685511262676
3 119825 119875 8146944792877919309
3 135103 135158 218634681842812119
3 127261 127352 13291431184...

output:


result:


Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Runtime Error

Test #31:

score: 0
Runtime Error

input:

300000 300000
1 85444 86076 59
1 41150 41411 71
1 278698 279414 45
1 238445 239202 56
1 29965 29984 49
1 282953 283272 37
1 34668 35653 86
2 198587 198744 28
1 270855 271611 58
1 2130 2965 773
1 161601 162298 937
1 50299 50435 36
1 100759 101198 64
1 120208 120543 84
1 295293 295732 34
1 112185 1129...

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%