QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#207114#7522. Sequence Shiftc20231020TL 2463ms33680kbC++238.8kb2023-10-08 09:36:452023-10-08 09:36:46

Judging History

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

  • [2023-10-08 09:36:46]
  • 评测
  • 测评结果:TL
  • 用时:2463ms
  • 内存:33680kb
  • [2023-10-08 09:36:45]
  • 提交

answer

/*
膜拜传奇特级宗师 Afterglow 大神儿
今天在 florr 首页称您为大夏尊贵的大名儿
一股敬佩之情油生然而
您在 florr 为国争光,扬我大夏威名
向您献上最真挚的膜拜!!!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
膜拜传奇特级宗师 Afterglow 大神儿,今,一,您,扬。向!
*/
/*
          _____                    _____                     _____                    _____
         /\    \                  /\    \                   /\    \                  /\    \
        /  \    \                /  \    \                 /  \____\                /  \    \
        \   \    \              /    \    \               /   /    /                \   \    \
         \   \    \            /      \    \             /   /    /                  \   \    \
          \   \    \          /   /\   \    \           /   /____/                    \   \    \
           \   \    \        /   /  \   \    \         /    |    |                     \   \    \
            \   \    \      /   /    \   \    \       /     |    |                      \   \    \
             \   \    \    /   /    / \   \    \     /      |    |                       \   \    \
              \   \    \  /   /    /   \   \    \   /       |____|__ _____                \   \    \
_______________\   \____\/   /____/     \   \    \ /   /|            \    \ _______________\   \____\
\                  /    /\   \    \      \   \    \\  / |    _________\____\\                  /    /
 \    ____________/____/  \   \    \      \   \____\\/__|   |    |           \    ____________/____/
  \   \    \               \   \    \     |   |    |    |   |    |            \   \    \
   \   \    \               \   \    \    |   |    |    |   |    |             \   \    \
    \   \    \               \   \    \   |   |____|    |   |    |              \   \    \
     \   \    \               \   \    \  /   /    /    \   |    |               \   \    \
      \   \    \               \   \    \/   /    /      \  |    |                \   \    \
       \   \____\               \   \___/   /    /        \ |    |                 \   \____\
        \  /    /                \         /    /          \|    |                  \  /    /
         \/____/                  \_______/____/            \____|                   \/____/
*/
#pragma GCC optimize(3,"Ofast")
#define poj
#define zcz
#ifdef poj
//C++
#include<iomanip>
#include<iostream>
//C
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
//STL
#include<algorithm>
#include<bitset>
#include<functional>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<vector>
//C++11
#if __cplusplus>=201103L
#include<chrono>
#include<random>
#include<unordered_set>
#include<unordered_map>
#endif
#else
#include<bits/stdc++.h>
#endif
using namespace std;
#ifdef zcz
class fastin{
	private:
#ifdef poj
	static const int MAXBF=1<<20;
#else
	const int MAXBF=1<<27;
#endif
	FILE *inf;
	char *inbuf,*inst,*ined;
	inline char _getchar(){
		if(inst==ined)inst=inbuf,ined=inbuf+fread(inbuf,1,MAXBF,inf);
		return inst==ined?EOF:*inst++;
	}
	public:
	fastin(FILE*_inf=stdin){
		inbuf=new char[MAXBF],inf=_inf,inst=inbuf,ined=inbuf;
	}
	~fastin(){delete[]inbuf;}
	template<typename Int> fastin&operator>>(Int &n){
		static char c;
		Int t=1;
		while((c=_getchar())<'0'||c>'9')if(c=='-')t=-1;
		n=(c^48);
		while((c=_getchar())>='0'&&c<='9')n=n*10+(c^48);
		n*=t;
		return *this;
	}
	fastin&operator>>(char&c){
		while((c=_getchar())<'!'||c>'~');
		return *this;
	}
	fastin&operator>>(char*s){
		int t=0;
		static char c;
		while((c=_getchar())==' '||c=='\n');
		s[t++]=c;
		while((c=_getchar())>='!'&&c<='~')s[t++]=c;
		s[t]='\0';
		return *this;
	}
}fi;
class fastout{
	private:
#ifdef poj
	static const int MAXBF=1<<20;
#else
	const int MAXBF=1<<27;
#endif
	FILE *ouf;
	char *oubuf,*oust,*oued;
	inline void _flush(){fwrite(oubuf,1,oued-oust,ouf);oued=oust;}
	inline void _putchar(char c){
		if(oued==oust+MAXBF)_flush(),oued=oubuf;
		*oued++=c;
		#ifdef local
		_flush();
		#endif
	}
	public:
	fastout(FILE*_ouf=stdout){
		oubuf=new char[MAXBF],ouf=_ouf,oust=oubuf,oued=oubuf;
	}
	~fastout(){_flush();delete[]oubuf;}
	template<typename Int> fastout&operator<<(Int n){
		if(n<0)_putchar('-'),n=-n;
		static char S[20];
		int t=0;
		do{S[t++]='0'+n%10,n/=10;}while(n);
		for(int i=0;i<t;++i)_putchar(S[t-i-1]);
		return *this;
	}
	fastout&operator<<(char c){_putchar(c);return *this;}
	fastout&operator<<(char*s){
		for(int i=0;s[i];++i)_putchar(s[i]);
		return *this;
	}
	fastout&operator<<(const char*s){
		for(int i=0;s[i];++i)_putchar(s[i]);
		return *this;
	}
}fo;
#define cin fi
#define cout fo
#else
#define czc ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#endif
#define mod7 1000000007
#define mod9 998244353
#define ll long long
#define isinf 0x3f3f3f3f
#define ilinf 0x7fffffff
#define lsinf 0x3f3f3f3f3f3f3f3f
#define llinf 0x7fffffffffffffff
#define pii pair<int,int>
#define fr first
#define sc second
#define next ___
#define pb push_back
#define N 2000010
#define M 5000010
#define For(i,a,b) for(ll i=(a);i<=(b);++i)
#define Rep(i,a,b,c) for(ll i=(a);i<=(b);i+=c)
#define Per(i,a,b,c) for(ll i=(a);i>=(b);i-=c)
#define Gra(i) for(ll i=h[x];i;i=next[i])
typedef int arr[N];
typedef int arm[M];
typedef ll arl[N];
typedef ll alm[M];
typedef double ard[N];
typedef double adm[M];
namespace modint{
	template<typename Int,Int mod,Int m1>
	struct modint{
		Int v;
		modint(){v=0;}
		modint(Int a){v=a;}
		bool operator==(modint a){return v==a.v;}
		bool operator!=(modint a){return v!=a.v;}
		bool operator<(modint a){return v<a.v;}
		bool operator>(modint a){return v>a.v;}
		bool operator<=(modint a){return v<=a.v;}
		bool operator>=(modint a){return v>=a.v;}
		bool operator==(Int a){return v==a;}
		bool operator!=(Int a){return v!=a;}
		bool operator<(Int a){return v<a;}
		bool operator>(Int a){return v>a;}
		bool operator<=(Int a){return v<=a;}
		bool operator>=(Int a){return v>=a;}
		friend bool operator==(Int a,modint b){return b==a;}
		friend bool operator!=(Int a,modint b){return b!=a;}
		friend bool operator<(Int a,modint b){return b>a;}
		friend bool operator>(Int a,modint b){return b<a;}
		friend bool operator<=(Int a,modint b){return b>=a;}
		friend bool operator>=(Int a,modint b){return b<=a;}
		modint operator+(modint a){return v>=mod-a.v?v-mod+a.v:v+a.v;}
		modint operator-(modint a){return v>=a.v?v-a.v:v+mod-a.v;}
		modint modnum(modint a){
			return a-((__int128(a.v)*m1)>>80)*mod;
		}
		modint operator*(modint a){return modnum(v*a.v);}
		modint operator+=(modint a){*this=*this+a;return *this;}
		modint operator-=(modint a){*this=*this-a;return *this;}
		modint operator*=(modint a){*this=*this*a;return *this;}
		modint qpow(modint a,Int b){
			modint r(1);
			for(;b;b>>=1,a*=a)if(b&1)r*=a;
			return r;
		}
		modint operator/(modint a){return qpow(a,mod-2)*v;}
		modint operator/=(modint a){*this=*this/a;return *this;}
		modint&operator++(){*this=*this+1;return *this;}
		modint&operator--(){*this=*this-1;return *this;}
		const modint operator++(int){modint r=*this;++*this;return r;}
		const modint operator--(int){modint r=*this;--*this;return r;}
		friend modint operator+(Int a,modint b){return b+a;}
		friend modint operator-(Int a,modint b){return b-a;}
		friend modint operator*(Int a,modint b){return b*a;}
		friend modint operator/(Int a,modint b){return modint(a)/b;}
		#ifdef cout
		friend fastin&operator>>(fastin&in,modint&n){in>>n.v;return in;}
		friend fastout&operator<<(fastout&out,modint n){out<<n.v;return out;}
		#else
		friend istream&operator>>(istream&in,modint&n){in>>n.v;return in;}
		friend ostream&operator<<(ostream&out,modint n){out<<n.v;return out;}
		#endif
	};
	typedef modint<long long,1000000007,1208925811152148> int7;
	typedef modint<long long,998244353,1211051999424262> int9;
}
using namespace modint;
int n,m,q,a[N],b[N],ans[N],k,l;
pii t[N];
void solve(){
	cin>>n>>q;
	m=n+q;
	For(i,1,n){
		cin>>a[i];
		t[i]={a[i],i};
	};
	sort(t+1,t+1+n,greater<pii>());
	k=max(1,min(n,(int)(1.0*n/(n+m)*sqrt(n*2*log2(1.0*n*q/m)))));
	l=t[k].fr+1e9*(m-k+1)/m;
	For(i,1,m){
		cin>>b[i];
		if(i>n)b[i]^=ans[i-1];
		For(j,1,n){
			int v=t[j].fr+b[i];
			if(v<l)break;
			int x=i+n-t[j].sc;
			if(x>=n&&x<=m)ans[x]=max(ans[x],v);
		};
		if(i>=n){
			if(ans[i])cout<<ans[i]<<'\n';
			else{
				int v=0;
				For(j,1,n)v=max(v,a[j]+b[i+j-n]);
				cout<<(ans[i]=v)<<'\n';
			}
		}
	};
	return;
}
int main(){
	#ifndef zcz
	czc;
	#endif
	int t=1;
	while(t--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 9556kb

input:

5 3
1 4 3 2 5
7 5 8 3 2
3
6
4

output:

11
13
16
25

result:

ok 4 lines

Test #2:

score: 0
Accepted
time: 1ms
memory: 9900kb

input:

1 0
103509429
823330096

output:

926839525

result:

ok single line: '926839525'

Test #3:

score: 0
Accepted
time: 1ms
memory: 9696kb

input:

1 1
576560149
691846236
1156187222

output:

1268406385
835582012

result:

ok 2 lines

Test #4:

score: 0
Accepted
time: 1ms
memory: 9620kb

input:

1 10
700282491
332230980
90825676
1630266999
644973380
262379760
2122877054
1851957134
1370195232
110993724
1319359505
1883523208

output:

1032513471
1654684398
759763732
888538827
1695749302
1163465539
1425605448
789576931
1397740634
1202288326
1638577353

result:

ok 11 lines

Test #5:

score: 0
Accepted
time: 12ms
memory: 11324kb

input:

1000 100000
438001359 929744877 710148392 323984311 727016267 323629255 495752276 309120511 312675195 717795522 937464489 624952229 444774478 829169766 707441777 609125148 25459976 849166512 716162953 882416779 189669312 135698832 632796131 592794700 569746403 231058028 389412868 824283503 801480367...

output:

1962871590
1986083253
1967509108
1973351244
1974354421
1956371849
1976394149
1995721753
1946870160
1984280254
1961237540
1955903880
1944520591
1937726835
1993563403
1927000559
1951483558
1979133252
1979156812
1941301401
1922284543
1980597785
1963663583
1946961524
1933606347
1953947075
1953071855
194...

result:

ok 100001 lines

Test #6:

score: 0
Accepted
time: 0ms
memory: 9708kb

input:

10000 10000
760845880 236665988 765352292 817854026 789863420 399953246 270535243 932350041 48814223 670950468 456660682 416165008 999681497 666880584 56581573 134567049 403285848 144814129 973325555 23519957 518449311 738687225 345716065 2309498 477743569 555951695 911860717 920761968 569179690 349...

output:

1990514380
1974843876
1992500750
1994731468
1983411218
1986646709
1979643361
1990060423
1988174297
1983373232
1995134632
1989936349
1993187026
1988927807
1971595730
1988272839
1990590966
1981928791
1987819156
1987483957
1979800700
1986611531
1973877196
1995735988
1985734454
1987573480
1988935268
199...

result:

ok 10001 lines

Test #7:

score: 0
Accepted
time: 95ms
memory: 11772kb

input:

10000 100000
682604470 430466819 955519058 186918998 587587373 201134122 473675328 586747694 132807628 255672373 504315038 137082392 753499284 586570202 133549919 570424589 87103369 2142325 895908281 852456682 239920694 443878018 717067433 437134318 39426086 82137124 698018668 518394430 430778732 56...

output:

1984544998
1988859370
1989789541
1976833784
1995823502
1972653611
1991119857
1993356707
1986981779
1995476314
1995610828
1993831190
1996638827
1986403811
1989382087
1993806832
1989374332
1994121941
1983565702
1985256743
1996937615
1982877527
1995705250
1986803258
1991586243
1985584711
1989505176
199...

result:

ok 100001 lines

Test #8:

score: 0
Accepted
time: 13ms
memory: 11124kb

input:

100000 1000
765888053 833515469 84953776 797547408 412620563 765574495 334638552 473705288 279331343 321129745 718689650 778307179 205668791 48820839 279108389 210915881 711034474 688831194 230042027 856832739 427928795 151766103 505848143 403162288 459045522 979683261 59438197 871004123 755234923 6...

output:

1998969019
1997756723
1990964658
1992180114
1991311226
1996318953
1999238402
1997012356
1996382741
1993901604
1990703168
1997121645
1996347278
1990978439
1993663588
1996287457
1998005763
1997236433
1994552013
1995785880
1997513392
1998761277
1994793469
1993807193
1997817922
1990146164
1997588498
199...

result:

ok 1001 lines

Test #9:

score: 0
Accepted
time: 9ms
memory: 12768kb

input:

100000 10000
155192094 32355226 10722958 680788712 355467230 837266625 393682487 504944520 573979360 618892727 168735423 928295170 158663199 129313725 187722419 800899194 169961946 297789942 3327780 993559861 568700692 901642218 989795879 846649116 947423253 851741191 365690710 469648703 903510759 7...

output:

1998324839
1998650520
1996715356
1996337565
1994069244
1994071960
1994680032
1995482692
1995353396
1996020788
1998370988
1994450866
1997311656
1992935357
1998022252
1998633241
1998507677
1997594278
1996419001
1997075873
1997413924
1995735160
1995881483
1995263027
1997718803
1998739520
1997494429
199...

result:

ok 10001 lines

Test #10:

score: 0
Accepted
time: 30ms
memory: 14316kb

input:

100000 100000
38413036 456923902 821971466 586909482 636298728 158178471 84422915 632002470 34405999 882453211 922025994 294603996 207311349 526030511 417456448 362917277 456078308 435018316 47342069 47738636 642863127 189926256 40263985 58857249 119358305 864464366 83617839 485428518 305918980 9423...

output:

1996429420
1996287202
1997245731
1997158288
1998410767
1992680343
1996866185
1991187990
1993994382
1993278697
1998519189
1996981873
1996505587
1999396980
1996368678
1994926892
1995154606
1996246700
1998278411
1995699098
1998553319
1996046134
1996078476
1994270984
1993675913
1998307200
1994292194
199...

result:

ok 100001 lines

Test #11:

score: 0
Accepted
time: 2463ms
memory: 32664kb

input:

1000000 1000000
681721767 150525996 385619734 237403201 784389657 667934330 103476610 977301142 659915560 343444475 784049915 969172199 251161944 919517420 927740574 885570202 531822081 391391357 889183133 954725705 921897422 339841876 886216126 698710851 968534847 834323464 33830362 168121355 74737...

output:

1998411706
1999115826
1999454117
1998836657
1998794667
1998269776
1999755051
1999381591
1998357039
1998230113
1999809722
1999320829
1999229409
1999798765
1998535400
1998709328
1999265546
1997784237
1998664760
1999789557
1998603617
1999595456
1999705003
1998179238
1999135621
1998190124
1998561110
199...

result:

ok 1000001 lines

Test #12:

score: 0
Accepted
time: 2113ms
memory: 33212kb

input:

1000000 1000000
859805191 724074841 684432991 968065382 763738910 62670003 683505489 25517834 880849716 625748657 18118867 880475047 43737843 944343853 294935089 108242311 520102508 250671619 762613856 393989946 773993874 814765461 401323635 360776723 990848704 704633672 746924583 748546216 62586244...

output:

1999153565
1998922375
1997721720
1999093273
1998838958
1999407641
1998418249
1998250909
1998448991
1998131598
1999503251
1999133323
1999668728
1996876504
1998997127
1998456693
1998474784
1998680486
1998444192
1999742746
1999261645
1997944942
1998714408
1999571606
1998009280
1998932514
1999539785
199...

result:

ok 1000001 lines

Test #13:

score: 0
Accepted
time: 2456ms
memory: 33200kb

input:

1000000 1000000
37888615 592590981 983246249 993694860 743088164 607148780 708244769 663669119 101783871 203020135 692379306 642034791 686570637 118913390 516905412 890722932 508382934 550143369 931011874 538286891 771314519 434913239 771206953 582651106 718195265 574943880 460018804 34003781 649576...

output:

1999040870
1998389768
1998486987
1998750065
1999570046
1998999846
1998466959
1998597646
1998651765
1998920821
1999606259
1999460166
1998879438
1998432387
1998655595
1998499939
1999399124
1999009605
1999576501
1999096183
1998399197
1999426537
1999444674
1998133711
1998313687
1998704116
1998625599
199...

result:

ok 1000001 lines

Test #14:

score: 0
Accepted
time: 2339ms
memory: 32912kb

input:

1000000 1000000
921004743 166139826 722250995 314291633 577213225 446594852 288273648 711885811 27750731 190357022 366639746 403594534 624370727 143739823 884099927 968170849 936854848 409423632 99409892 832326940 918378268 55061017 286314462 99492785 740509122 5062601 173113025 54620130 528066880 5...

output:

1998252814
1999088948
1999154632
1998556605
1998012909
1997580019
1997826212
1997205871
1999347521
1998550231
1998806656
1998616565
1997661919
1999357225
1999738820
1999207108
1998644513
1998636528
1998692736
1998182183
1999138033
1997755290
1999060027
1998904028
1998479869
1999490247
1998535527
199...

result:

ok 1000001 lines

Test #15:

score: 0
Accepted
time: 2369ms
memory: 33680kb

input:

1000000 1000000
99088167 444721374 316031548 190178007 851529775 136297821 18045631 55069799 248684886 472661204 745932889 165154278 562170817 318309361 106070250 45618767 220102571 708895382 972840614 976623884 65442016 235017306 96389267 321367168 762822979 580405513 181174542 635044991 846748488 ...

output:

1999808816
1999546408
1999511887
1997972111
1999525416
1999177742
1998895382
1999301427
1998683427
1998451107
1999708795
1998116472
1998978702
1997379027
1999468104
1999286658
1996653439
1998936965
1998503852
1998407411
1999250564
1997961935
1998789825
1998485755
1997761086
1997724392
1998570689
199...

result:

ok 1000001 lines

Test #16:

score: 0
Accepted
time: 2371ms
memory: 33652kb

input:

1000000 1000000
277171591 168013322 760068998 215807485 685654837 680776598 188009103 398253787 469619041 754965386 420193329 221681318 205003612 48168498 473264766 123066684 353607189 568175644 846271336 270663933 917538469 855165084 316529481 838208847 490169540 450715721 894268763 920502556 57549...

output:

1998494838
1998423114
1999462821
1998426456
1998295744
1998682373
1999287674
1998826960
1997988135
1999740840
1999768385
1998924526
1998971787
1998394666
1998840068
1998843231
1998076944
1999414593
1997932895
1999093937
1998722730
1997826457
1997776964
1999737748
1999633669
1996811057
1999941569
199...

result:

ok 1000001 lines

Test #17:

score: -100
Time Limit Exceeded

input:

1000000 1000000
160287719 741562167 353849551 946469666 665004090 520222671 622813790 741437775 395585901 37269569 799486473 838016869 142803702 222738035 695235089 345738793 636854912 867647394 159893546 709928174 209826409 770280158 686412798 205307423 217516101 321025929 607362985 941118905 45398...

output:

1997970576
1999041782
1998693968
1997547266
1999353061
1998266739
1998901397
1998259083
1997873026
1998269849
1998703020
1998473742
1998956498
1997667670
1998060349
1997725444
1999041853
1998424607
1998915353
1997257162
1998930679
1998683778
1999496409
1999416754
1998303929
1998215765
1997695222
199...

result: