QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#772799#7449. rgxsxrsZaunese20 79ms18752kbC++146.0kb2024-11-22 21:55:022024-11-22 21:55:03

Judging History

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

  • [2024-11-22 21:55:03]
  • 评测
  • 测评结果:20
  • 用时:79ms
  • 内存:18752kb
  • [2024-11-22 21:55:02]
  • 提交

answer

//                              -    주의 만세!

#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<climits>

#define fi first
#define se second
#define mkp std::make_pair
using llu=long long unsigned;
using ll=long long;
using std::max;
using std::min;
template<class T> void cmax(T&a,T b){a=max(a,b);}
template<class T> void cmin(T&a,T b){a=min(a,b);}

namespace io{//{{{
	const int __SIZE=(1<<21)+1;
	char ibuf[__SIZE],*iS,*iT,obuf[__SIZE],*oS=obuf,*oT=oS+__SIZE-1,__c,qu[55];int __f,qr,_eof;
	#define Gc()(char)(iS==iT?(iT=(iS=ibuf)+fread(ibuf,1,__SIZE,stdin),(iS==iT?EOF:*iS++)):*iS++)
	inline void flush(){fwrite(obuf,1,oS-obuf,stdout),oS=obuf;}
	inline void gc(char&x){x=Gc();}
	inline void pc(char x){*oS++=x;if(oS==oT)flush();}
	inline void pstr(const char*s){int __len=(int)strlen(s);for(__f=0;__f<__len;++__f)pc(s[__f]);}
	inline void gstr(char*s){for(__c=Gc();__c<32||__c>126||__c==' ';)__c=Gc();
		for(;__c>31&&__c<127&&__c!=' '&&__c!='\n'&&__c!='\r';++s,__c=Gc())*s=__c;
        *s=0;}
	template<class I>inline bool gi(I&x){_eof=0;
		for(__f=1,__c=Gc();(__c<'0'||__c>'9')&&!_eof;__c=Gc()){if(__c=='-')__f=-1;_eof|=__c==EOF;}
		for(x=0;__c<='9'&&__c>='0'&&!_eof;__c=Gc())x=x*10+(__c&15),_eof|=__c==EOF;
        x*=__f;return!_eof;}
	template<class I>inline void pi(I x){if(!x)pc('0');if(x<0)pc('-'),x=-x;
		while(x)qu[++qr]=x%10+'0',x/=10;
        while(qr)pc(qu[qr--]);}
    template<class I>inline void pil(I x){pi(x);pc(10);}
    template<class I>inline void pis(I x){pi(x);pc(32);}
	struct Flusher_{~Flusher_(){flush();}}io_flusher_;
}using io::gi;using io::pi;using io::pis;using io::pil;//}}}

const int INF=INT_MAX;
ll lb[9],rb[9];
int getb(int x){
    int ans=1;
    while(x>rb[ans]) ++ans;
    return ans;
}
const int NV=1e5;
const int B=16;
int N,a[NV+5];

namespace seg{
    const int L=32;
    struct SEGN{
        ll s,cn,taf;
        int mx,mn;
    } tr[9][40005];
    void up(int b,int x){
        tr[b][x].s=tr[b][x*2].s+tr[b][x*2+1].s;
        tr[b][x].cn=tr[b][x*2].cn+tr[b][x*2+1].cn;
        tr[b][x].mx=max(tr[b][x*2].mx,tr[b][x*2+1].mx);
        tr[b][x].mn=min(tr[b][x*2].mn,tr[b][x*2+1].mn);
    }void dn(int b,int x){
        ll taf=tr[b][x].taf;
        if(!taf) return;
        if(tr[b][x*2].cn){
            tr[b][x*2].taf+=taf;
            tr[b][x*2].s-=taf*tr[b][x*2].cn;
            tr[b][x*2].mx-=taf;
            tr[b][x*2].mn-=taf;
        }
        if(tr[b][x*2+1].cn){
            tr[b][x*2+1].taf+=taf;
            tr[b][x*2+1].s-=taf*tr[b][x*2+1].cn;
            tr[b][x*2+1].mx-=taf;
            tr[b][x*2+1].mn-=taf;
        }
        tr[b][x].taf=0;
    }void bfdn(int b,int l,int r,ll&z){
        if(!z) return;
        for(int i=l;i<=r;++i) if(lb[b]<=a[i]&&a[i]<=rb[b]) a[i]-=z;
        z=0;
    }void bfup(int b,int x,int l,int r){
        tr[b][x].cn=tr[b][x].s=tr[b][x].mx=0;
        tr[b][x].mn=INF;
        for(int i=l;i<=r;++i) if(lb[b]<=a[i]&&a[i]<=rb[b]){
            ++tr[b][x].cn;
            tr[b][x].s+=a[i];
            cmax(tr[b][x].mx,a[i]);
            cmin(tr[b][x].mn,a[i]);
        }
    }void ins(int b,int x,int l,int r,int p,int z){
        if(r-l+1<=L){
            bfdn(b,l,r,tr[b][x].taf);
            a[p]=z;
            bfup(b,x,l,r);
            return;
        }
        int mid=l+r>>1;
        dn(b,x);
        if(p<=mid) ins(b,x*2,l,mid,p,z);
        else ins(b,x*2+1,mid+1,r,p,z);
        up(b,x);
    }void add(int b,int x,int l,int r,int ql,int qr,int z){
        if(tr[b][x].mx<=z) return;
        if(r-l+1<=L){
            bfdn(b,l,r,tr[b][x].taf);
            for(int i=max(l,ql);i<=min(r,qr);++i) if(lb[b]<=a[i]&&a[i]<=rb[b])
                if(a[i]>z){
                    a[i]-=z;
                    if(a[i]<lb[b]) ins(getb(a[i]),1,1,N,i,a[i]);
                }
            bfup(b,x,l,r);
            return;
        }
        if(ql<=l&&r<=qr&&tr[b][x].mn-z>=lb[b]){
            tr[b][x].mn-=z;
            tr[b][x].mx-=z;
            tr[b][x].taf+=z;
            tr[b][x].s-=z*tr[b][x].cn;
            return;
        }
        int mid=l+r>>1;
        dn(b,x);
        if(ql<=mid) add(b,x*2,l,mid,ql,qr,z);
        if(mid<qr) add(b,x*2+1,mid+1,r,ql,qr,z);
        up(b,x);
    }void que(int b,int x,int l,int r,int ql,int qr,ll&sum,int&mx,int&mn){
        if(ql<=l&&r<=qr){
            sum+=tr[b][x].s;
            cmax(mx,tr[b][x].mx);
            cmin(mn,tr[b][x].mn);
            return;
        }
        if(r-l+1<=L){
            bfdn(b,l,r,tr[b][x].taf);
            for(int i=max(l,ql);i<=min(r,qr);++i) if(lb[b]<=a[i]&&a[i]<=rb[b]){
                sum+=a[i];
                cmax(mx,a[i]);
                cmin(mn,a[i]);
            }
            return;
        }
        int mid=l+r>>1;
        dn(b,x);
        if(ql<=mid) que(b,x*2,l,mid,ql,qr,sum,mx,mn);
        if(mid<qr) que(b,x*2+1,mid+1,r,ql,qr,sum,mx,mn);
    }
}

namespace xm{
    void _(){
        for(int i=1;i<=8;++i)
        for(int j=0;j<40005;++j) seg::tr[i][j].mn=INF;

        int Q;

        gi(N);
        gi(Q);
        for(int i=1;i<=8;++i){
            lb[i]=rb[i-1]+1;
            rb[i]=lb[i]*B-1;
        }
        for(int i=1;i<=N;++i){
            gi(a[i]);
            seg::ins(getb(a[i]),1,1,N,i,a[i]);
        }

        int lastans=0;
        while(Q--){
            int op,l,r;
            gi(op);
            gi(l);
            gi(r);
            l^=lastans;
            r^=lastans;
            if(op==1){
                int x;
                gi(x);
                x^=lastans;
                for(int i=1;i<=8;++i) if(rb[i]>=x) seg::add(i,1,1,N,l,r,x);
            }else{
                ll sum=0;
                int mx=0,mn=INF;
                for(int i=1;i<=8;++i) seg::que(i,1,1,N,l,r,sum,mx,mn);
                pis(sum);
                pis(mn);
                pil(mx);
                lastans=sum%(1<<20);
            }
        }
    }
}

int main(){
    xm::_();
    return 0;
}

详细

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 0ms
memory: 14604kb

input:

1000 1000
935816535 513713699 701239859 881761843 312245068 749043434 112422339 4851733 369182510 741607986 336173081 76013815 91837056 23042507 28754006 935721035 332487169 739344582 280604892 549629633 428486579 693745524 772744523 736620619 596867287 553364838 842666116 620926490 350404590 972861...

output:

265016378473 746807 999055631
666065535 666065535 666065535
271006237166 746807 999055631
244146031651 726339 992039812
15823858743 7712227 991422034
1807891893 93288403 840436769
17240518274 746807 968670509
110636754727 726339 817084515
57343541330 746807 806807028
41246731402 746807 770270334
588...

result:

ok 1575 numbers

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 26ms
memory: 18752kb

input:

200000 200000
10 7 6 1 5 5 10 1 9 4 7 1 5 4 8 9 5 7 10 2 10 3 3 5 5 2 1 4 10 5 7 2 6 1 3 1 6 4 7 5 3 1 3 2 9 5 4 10 8 3 10 4 4 8 5 4 6 10 4 10 9 6 7 4 6 7 7 6 2 6 6 10 10 6 8 8 9 4 6 3 3 9 8 1 8 5 8 2 7 3 1 10 5 10 1 5 8 5 6 6 7 9 7 3 5 8 4 4 3 2 9 3 10 2 5 4 2 2 6 3 3 5 8 4 2 1 2 9 2 3 6 3 8 9 4 10...

output:

5 5 5
44 1 10
0 2147483647 0
0 2147483647 0
34 1 10
0 2147483647 0
20 5 10
0 2147483647 0
34 1 10
0 2147483647 0
23 6 10
0 2147483647 0
0 2147483647 0
0 2147483647 0
10 10 10
0 2147483647 0
29 1 10
0 2147483647 0
27 1 10
0 2147483647 0
0 2147483647 0
21 1 10
0 2147483647 0
15 5 10
0 2147483647 0
10 ...

result:

wrong answer 1st numbers differ - expected: '8548', found: '5'

Subtask #3:

score: 0
Wrong Answer

Test #5:

score: 0
Wrong Answer
time: 51ms
memory: 17940kb

input:

200000 200000
615 736 846 534 658 429 631 720 898 583 797 295 303 336 449 358 57 338 954 414 330 212 171 200 403 553 308 20 805 249 767 291 545 196 324 928 439 197 20 601 737 748 817 858 816 130 403 858 813 936 771 242 833 863 978 260 357 856 954 89 673 733 364 473 903 445 823 894 49 747 382 56 309 ...

output:

0 2147483647 0
15612183 1 4095
0 2147483647 0
0 2147483647 0
12460082 1 4095
0 2147483647 0
13259 21 969
0 2147483647 0
16364 26 990
0 2147483647 0
0 2147483647 0
3158862 1 1000
0 2147483647 0
21815467 1 4095
0 2147483647 0
40549681 1 4095
0 2147483647 0
18709090 1 4095
0 2147483647 0
6235794 1 1000...

result:

wrong answer 1st numbers differ - expected: '4143168', found: '0'

Subtask #4:

score: 0
Wrong Answer

Test #8:

score: 0
Wrong Answer
time: 79ms
memory: 18124kb

input:

200000 200000
78066 141247 11068 105207 26127 179253 104948 145839 150954 60877 67556 61673 69638 150806 127596 162902 125410 38242 97645 20582 193537 139906 114184 129867 126626 85640 91551 19445 134855 85251 22162 3798 122992 38278 131907 96159 153440 94561 185234 15296 76886 108452 70560 77355 14...

output:

0

result:

wrong output format Expected integer, but "0

Subtask #5:

score: 0
Runtime Error

Test #12:

score: 0
Runtime Error

input:

500000 500000
56 22353719 15918 54 13 1 389 7 809 2204 75911688 4218278 36 7205 93542078 506 4761175 102646343 48 65900 10 228 2 292994 26348644 6 19339 148 704 232124395 19307 52070 8964343 7430314 42755 115 869 32485365 252183868 481162087 852632 38758 2945883 279412 15012 82 33076951 1537 6954898...

output:


result: