QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#208601#7522. Sequence ShiftqLTL 830ms8148kbC++1415.6kb2023-10-09 19:19:052023-10-09 19:19:05

Judging History

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

  • [2023-10-09 19:19:05]
  • 评测
  • 测评结果:TL
  • 用时:830ms
  • 内存:8148kb
  • [2023-10-09 19:19:05]
  • 提交

answer

#include<cstdio>
#include<utility>
#include<cstdlib>
#include<type_traits>
#include<array>
#include<algorithm>
/**
 * 写得死烂,又长又慢。
 * Author:qL
 * todo:
 * Better modInt
 * frac
 * More Poly
 * fix bug of radix_sort
 * new IO
 * turn std::enable_if into static_assert 
*/
namespace QL{
	/**
	 * 图方便用的
	*/
	namespace{
		using ll=long long;
		using ull=unsigned long long;
		using uint=unsigned int;
		using db=double;
		using ld=long double;
#if _GLIBCXX_USE_INT128
		using lll=__int128;
		using ulll=unsigned __int128;
#else
		using lll=long long;
		using ulll=unsigned long long;
#endif
#if _GLIBCXX_NUMERIC&&(__cplusplus>=201703L)
		template<typename _Tp>
		constexpr _Tp Inf=std::numeric_limits<_Tp>::max()/2;
#else
		constexpr int Inf=0x3f3f3f3f;
		constexpr long long llInf=0x3f3f3f3f3f3f3f3f;
		constexpr double dbInf=1e17;
		constexpr long double ldInf=1e22;
#endif
#ifndef _GLIBCXX_CMATH
	#define sqrt __builtin_sqrt
	#define sqrtf __builtin_sqrtf
	#define sqrtl __builtin_sqrtl
	#define ceil __builtin_ceil
	#define ceilf __builtin_ceilf
	#define ceill __builtin_ceill
	#define floor __builtin_floor
	#define floorf __builtin_floorf
	#define floorl __builtin_floorl
	#define log2 __builtin_log2
	#define log __builtin_log
	#define cos __builtin_cos
	#define sin __builtin_sin
	#define tan __builtin_tan
	#define acos __builtin_acos
#endif
#ifndef _GLIBCXX_CSTRING
	#define memset __builtin_memset
	#define memcpy __builtin_memcpy
	#define strlen __builtin_strlen
	#define strcmp __builtin_strcmp
#endif
#ifndef _GLIBCXX_CSTDIO
	#define fwrite __builtin_fwrite
	#define putchar __builtin_putchar
	#define fputc __builtin_fputc
	#define fputs __builtin_fputs
#endif
#ifndef likely
	#define likely(x) __builtin_expect(!!(x),1)
#endif
#ifndef unlikely
	#define unlikely(x) __builtin_expect(!!(x),0)
#endif
	}
	/**
	 * 不想多加头文件了……
	*/
	namespace Error{
		constexpr void make_re(int _seed_=114514){
			std::exit(_seed_);
		}
#ifndef _GLIBCXX_CASSERT
		constexpr bool assert(bool x,const char *reason="Assert: RE"){
			if(unlikely(!x)){
				fputs(reason,stderr);
				fputs(reason,stdout);
				make_re();
			}
			return false;
		}
		constexpr bool assert(bool x,char *reason){
			return assert(x,const_cast<const char *>(reason));
		}
#endif
	}
}
namespace QL{
	/**
	 * 这坨代码最让人难以理解的地方:没逝乱靠元编程库
	*/
	namespace Traits_Tools{
		template<typename _Tp>
		class has_member_swap{
		private:
			template<typename T>
			static auto Check(void)->decltype(std::declval<T>().swap(),std::true_type());
			template<typename T>
			static std::false_type Check(...);
		public:
			enum{value=std::is_same<decltype(Check<_Tp>(nullptr)),std::true_type>::value};
		};
		#define Operator_Check_Helper(name,opt) \
				template<typename _Tp1,typename _Tp2> \
				class has_operator_##name{ \
				private: \
					template<typename T1,typename T2> \
					static auto Check(void)->decltype(std::declval<T1,T2>().operator opt (),std::true_type()); \
					template<typename T1,typename T2> \
					static std::false_type Check(...); \
				public: \
					enum{value=std::is_same<decltype(Check<_Tp1,_Tp2>(nullptr)),std::true_type>::value}; \
				};
		Operator_Check_Helper(plus,+)
		Operator_Check_Helper(subtract,-)
		Operator_Check_Helper(multiply,*)
		Operator_Check_Helper(divide,/)
		Operator_Check_Helper(mod,%)
		Operator_Check_Helper(and,&)
		Operator_Check_Helper(or,|)
		Operator_Check_Helper(xor,^)
		#undef Operator_Check_Helper
		template<typename _Tp,typename std::enable_if<std::is_integral<_Tp>::value>::type* =nullptr>
		struct to_upper_type;
		#define To_Upper_Helper(_type_,_upper_) \
		template<> \
		struct to_upper_type< _type_ >{ \
			using type=_upper_; \
		}; \
		template<> \
		struct to_upper_type< u##_type_ >{ \
			using type=u##_upper_; \
		};
		To_Upper_Helper(int,ll)
		To_Upper_Helper(ll,lll)
		#undef To_Upper_Helper
	}
}
namespace QL{
	namespace rel_ops{
		namespace Calc_Self{
			#define Calc_Self_Helper(opt) \
			template<typename _Tp1,typename _Tp2> \
			constexpr _Tp1 &operator opt##=(_Tp1 &lhs,const _Tp2 &rhs){ \
				return lhs=(lhs opt rhs); \
			}
			Calc_Self_Helper(+)
			Calc_Self_Helper(-)
			Calc_Self_Helper(*)
			Calc_Self_Helper(/)
			Calc_Self_Helper(%)
			Calc_Self_Helper(&)
			Calc_Self_Helper(|)
			Calc_Self_Helper(^)
			#undef Calc_Self_Helper
		}
		namespace Compare{
			template<typename _Tp1,typename _Tp2>
			constexpr bool operator!=(const _Tp1 &lhs,const _Tp2 &rhs){
				return !(lhs==rhs);
			}
			template<typename _Tp1,typename _Tp2>
			constexpr bool operator<=(const _Tp1 &lhs,const _Tp2 &rhs){
				return (lhs==rhs)||(lhs<rhs);
			}
			template<typename _Tp1,typename _Tp2>
			constexpr bool operator>(const _Tp1 &lhs,const _Tp2 &rhs){
				return !((lhs==rhs)||(lhs<rhs));
			}
			template<typename _Tp1,typename _Tp2>
			constexpr bool operator>=(const _Tp1 &lhs,const _Tp2 &rhs){
				return !(lhs<rhs);
			}
		}
	}
}
/**
 * todo:
 * rebuild
 */
namespace QL{
	namespace Base_Tools{
		template<typename _Tp>
		static constexpr std::size_t integer_length=sizeof(_Tp)*10/sizeof(int);
		bool is_space(char ch){
			return ch==' ';
		}
		bool is_eoln(char ch){
#if (linux||__linux__||__linux)
			return ch=='\n'||ch=='\r';
#else
			return ch=='\n';
#endif
		}
		bool is_blank(char ch){
			return is_space(ch)||is_eoln(ch);
		}
		bool is_digit(char ch){
			switch(ch){
				case '0' ... '9': return true;
				default: return false;
			}
		}
		bool is_eof(char ch){
			return ch==EOF;
		}
	}
	namespace IO{
		using Base_Tools::integer_length;
		using Base_Tools::is_digit;
		using Base_Tools::is_space;
		using Base_Tools::is_eoln;
		using Base_Tools::is_blank;
		using Base_Tools::is_eof;
		/**
		 * fread+fwrite,-DLOACL for debug
		 * support:integer,floating,string,...
		 * todo:other
 		*/
		class IOstream{
		protected:
			using LIST=std::initializer_list<int>;
#ifndef LOCAL
			std::FILE *IN;
			std::FILE *OUT;
			static constexpr int SIZE=1<<15;
			char buf[SIZE]{},*p1{buf},*p2{buf},obuf[SIZE]{},*p3{obuf};
		public:
			char pull(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,SIZE,IN),p1==p2)?(Ch=EOF):*p1++;}
			void push(char ch){((p3-obuf)==SIZE&&(flush(false),0)),*p3++=ch;}
			template<std::size_t L>
			std::FILE *set_in(const char (&name)[L]){
				static char in[L+5]={};
				std::sprintf(in,"%s.in",name);
				return std::fopen(in,"r");
			}
			template<std::size_t L>
			std::FILE *set_out(const char (&name)[L]){
				static char out[L+5];
				std::sprintf(out,"%s.out",name);
				return std::fopen(out,"w");
			}
#else
		protected:
		public:
			char pull(){return std::getchar();}
			void push(char ch){putchar(ch);}
			void err(char ch){fputc(ch,stderr);}
			template<std::size_t L>
			void set_in(const char(&name)[L]){
				static char in[L+5]={};
				std::sprintf(in,"%s.in",name);
				std::freopen(in,"r",stdin);
			}
			template<std::size_t L>
			void set_out(const char(&name)[L]){
				static char out[L+5];
				std::sprintf(out,"%s.out",name);
				std::freopen(out,"w",stdout);
			}
#endif
		public:
#ifndef LOCAL
			IOstream():IN{stdin},OUT{stdout},buf{},p1{buf},p2{buf},obuf{},p3{obuf},Ch{'\n'},outchar{&IO::IOstream::push}{}
			template<std::size_t L>
			IOstream(const char(&name)[L]):IN{set_in(name)},OUT{set_out(name)},buf{},p1{buf},p2{buf},obuf{},p3{obuf},Ch{'\n'},outchar{&IO::IOstream::push}{}
			template<std::size_t L>
			IOstream(const char(&name)[L],bool in,bool out):IN{in?set_in(name):stdin},OUT{out?set_out(name):stdout},buf{},p1{buf},p2{buf},obuf{},p3{obuf},Ch{'\n'},outchar{&IO::IOstream::push}{}
			template<std::size_t L>
			IOstream(char(&name)[L]):IN{set_in(name)},OUT{set_out(name)},buf{},p1{buf},p2{buf},obuf{},p3{obuf},Ch{'\n'},outchar{&IO::IOstream::push}{}
			template<std::size_t L>
			IOstream(char(&name)[L],bool in,bool out):IN{in?set_in(name):stdin},OUT{out?set_out(name):stdout},buf{},p1{buf},p2{buf},obuf{},p3{obuf},Ch{'\n'},outchar{&IO::IOstream::push}{}
			~IOstream(){flush();}
			void flush(bool _flush_=false){
				if(likely(p3!=obuf))
					fwrite(obuf,1,p3-obuf,OUT),p3=obuf;
				if(_flush_) std::fflush(stdout);
			}
#else
			IOstream(){}
			template<std::size_t L>
			IOstream(const char(&name)[L]):Ch{'\n'}{reset_stdin(name),reset_stdout(name);}
			template<std::size_t L>
			IOstream(const char(&name)[L],bool in,bool out):Ch{'\n'}{in&&(reset_stdin(name),0),out&&(reset_stdout(name),0);}
			template<std::size_t L>
			IOstream(char(&name)[L]):Ch{'\n'}{reset_stdin(name),reset_stdout(name);}
			template<std::size_t L>
			IOstream(char(&name)[L],bool in,bool out):Ch{'\n'}{in&&(reset_stdin(name),0),out&&(reset_stdout(name),0);}
			void flush(bool _flush_=true){
				if(_flush_) std::fflush(stdout);
			}
#endif
			template<typename T>
			T read(){
				T x;
				read(x);
				return x;
			}
protected:
			char Ch='\n';
public:
			bool eof(void)const{
				return Ch==EOF;
			}
			template<typename T>
			void read(T &&x,typename std::enable_if<std::is_integral<T>::value,void>::type* =nullptr,typename std::enable_if<std::is_signed<T>::value,void>::type* =nullptr){
				x=0;bool flag=0;
				for(;!is_digit(Ch)&&!is_eof(Ch);Ch=pull()) if(Ch=='-') flag=1;
				if(is_eof(Ch)) return;
				if(flag) for(;is_digit(Ch);Ch=pull()) x=x*10-(Ch&15);
				else for(;is_digit(Ch);Ch=pull()) x=x*10+(Ch&15);
			}
			template<typename T>
			void read(T &&x,typename std::enable_if<std::is_integral<T>::value,void>::type* =nullptr,typename std::enable_if<std::is_unsigned<T>::value,void>::type* =nullptr){
				x=0;
				for(;!is_digit(Ch)&&!is_eof(Ch);Ch=pull());
				if(is_eof(Ch)) return;
				for(;is_digit(Ch);Ch=pull()) x=x*10+(Ch&15);
			}
			void read(char *str){
				for(;is_blank(Ch);Ch=pull());
				if(is_eof(Ch)) return (void)(*str='\0');
				for(;!is_blank(Ch)&&!is_eof(Ch);Ch=pull()) *str++=Ch;
				*str='\0';
			}
			void read(char &c){
				c=Ch;
				for(;is_blank(c)&&!is_eof(c);c=pull());
				if(is_eof(c)) return;
				Ch=pull();
			}
			void read(bool &x){
				for(;Ch!='0'&&Ch!='1'&&!is_eof(Ch);Ch=pull());
				if(is_eof(Ch)) return void(x=false);
				x=Ch=='1';
				Ch=pull();
			}
			template<typename T>
			void read(T &&x,typename std::enable_if<std::is_floating_point<T>::value,void*>::type* =nullptr){
				static char str[114];
				read(str);
				x=std::atof(str);
			}
			template<typename T>
			void read(T &x){read(std::move(x));}
		protected:
			void(IOstream::*outchar)(char)=&IO::IOstream::push;
			template<typename T>
			void out(T x,typename std::enable_if<std::is_integral<T>::value,void>::type* =nullptr,typename std::enable_if<std::is_signed<T>::value,void>::type* =nullptr){
				static char sta[integer_length<T>];
				int top=0;
				if(x<0){
					(this->*outchar)('-');
					do sta[top++]=((-x)%10)|48,x/=10;
					while(x);
				}
				else{
					do sta[top++]=(x%10)|48,x/=10;
					while(x);
				}
				while(top) (this->*outchar)(sta[--top]);
			}
			template<typename T>
			void out(T x,typename std::enable_if<std::is_integral<T>::value,void>::type* =nullptr,typename std::enable_if<std::is_unsigned<T>::value,void>::type* =nullptr){
				static char sta[integer_length<T>];
				int top=0;
				do sta[top++]=(x%10)|48,x/=10;
				while(x);
				while(top) (this->*outchar)(sta[--top]);
			}
			void out(bool x){(this->*outchar)(x?'1':'0');}
			void out(char x){(this->*outchar)(x);}
			void out(char *str){
				out(reinterpret_cast<const char *>(str));
			}
			void out(const char *str){
				while(*str!='\0') (this->*outchar)(*str++);
			}
			/**
			 * ssprintf is awful...
			 */
			void out(float x){
				static char str[114];
				std::sprintf(str,"%f",x);
				out(str);
			}
			void out(double x){
				static char str[114];
				std::sprintf(str,"%f",x);
				out(str);
			}
			void out(long double x){
				static char str[114];
				std::sprintf(str,"%Lf",x);
				out(str);
			}
			void out(std::pair<int,float> x){
				static char str[114],opt[10];
				std::sprintf(opt,"%%.%df",x.first);
				std::sprintf(str,opt,x.second);
				out(str);
			}
			void out(std::pair<int,double> x){
				static char str[114],opt[10];
				std::sprintf(opt,"%%.%df",x.first);
				std::sprintf(str,opt,x.second);
				out(str);
			}
			void out(std::pair<int,long double> x){
				static char str[114],opt[10];
				std::sprintf(opt,"%%.%dLf",x.first);
				std::sprintf(str,opt,x.second);
				out(str);
			}
			void set_std_out(){outchar=&IO::IOstream::push;}
#ifdef LOCAL
			void set_err_out(){outchar=&IO::IOstream::err;}
#endif
		public:
			template<typename...Args>
			void read(Args &&...args){(void)LIST{(read(args),0)...};}
			template<typename...Args>
			void write(Args...args){set_std_out(),(void)LIST{(out(args),0)...};}
			template<typename...Args>
			void writeln(Args...args){write(args...),push('\n');}
#ifdef LOCAL
			template<typename...Args>
			void error(Args...args){set_err_out(),(void)LIST{(out(args),0)...};}
			template<typename...Args>
			void errorln(Args...args){error(args...),err('\n');}
#endif
		};
	}
}
namespace QL{
	namespace Base_Tools{
		template<typename _Tp1,typename _Tp2>
		constexpr auto min(_Tp1 x,_Tp2 y){
			return x<y?x:y;
		}
		template<typename _Tp,typename ...Args>
		constexpr auto min(_Tp x,Args ...args){
			return min(x,min(args...));
		}
		template<typename _Tp1,typename _Tp2>
		constexpr auto max(_Tp1 x,_Tp2 y){
			return y<x?x:y;
		}
		template<typename _Tp,typename ...Args>
		constexpr auto max(_Tp x,Args ...args){
			return max(x,max(args...));
		}
		template<typename _Tp1,typename _Tp2>
		constexpr bool chkmin(_Tp1 &x,_Tp2 y){
			return y<x?(x=y,true):false;
		}
		template<typename _Tp1,typename _Tp2,typename...Args>
		constexpr bool chkmin(_Tp1 &x,_Tp2 y,Args ...args){
			return chkmin(x,y)|chkmin(x,args...);
		}
		template<typename _Tp1,typename _Tp2>
		constexpr bool chkmax(_Tp1 &x,_Tp2 y){
			return x<y?(x=y,true):false;
		}
		template<typename _Tp1,typename _Tp2,typename...Args>
		constexpr bool chkmax(_Tp1 &x,_Tp2 y,Args ...args){
			return chkmax(x,y)|chkmax(x,args...);
		}
		template<typename _Tp,
		typename std::enable_if<!Traits_Tools::has_member_swap<_Tp>::value&&!std::is_integral<_Tp>::value>::type* =nullptr>
		constexpr void swap(_Tp &x,_Tp &y){
			_Tp tmp;
			tmp=x,x=y,y=tmp;
		}
		template<typename _Tp,typename std::enable_if<std::is_integral<_Tp>::value>::type* =nullptr>
		constexpr void swap(_Tp &x,_Tp &y){
			x!=y&&(x^=y^=x^=y);
		}
		template<typename _Tp>
		constexpr void swap(_Tp *&x,_Tp *&y){
			_Tp *tmp;
			tmp=x,x=y,y=tmp;
		}
		template<typename _Tp,typename std::enable_if<Traits_Tools::has_member_swap<_Tp>::value>::type* =nullptr>
		constexpr void swap(_Tp &x,_Tp &y){
			x.swap(y);
		}
		template<typename _Tp>
		constexpr _Tp abs(const _Tp &x){
			return x<0?-x:x;
		}
	}
}
namespace MAIN{
	using namespace QL;
	IO::IOstream lq;
    constexpr int N=1e6+5;
    int n,q,b[N*2];
	struct{int x,id;} a[N];
	void _main_(void){
        lq.read(n,q),++q;
		int lim=1e9*Base_Tools::max(2-7/sqrt(n),0);
        for(int i=1;i<=n;++i) lq.read(a[i].x),a[i].id=i;
        for(int i=1;i<n;++i) lq.read(b[i]);
		std::sort(a+1,a+n+1,[](auto x,auto y){return x.x<y.x;});
		for(int i=1,st=1,ed=n,ans=0;i<=q;++i,++st,++ed){
			lq.read(b[ed]),b[ed]^=ans,ans=0;
			for(int i=1,tmp;i<=n;++i){
				if((tmp=a[i].x+b[a[i].id+st-1])<lim) break;
				Base_Tools::chkmax(ans,tmp);
			}
			if(!ans)
				for(int i=1;i<=n;++i) Base_Tools::chkmax(ans,a[i].x+b[a[i].id+st-1]);
			lq.writeln(ans);
		}
		return;
	}
}
signed main(){
	return MAIN::_main_(),0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 5712kb

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: 5788kb

input:

1 0
103509429
823330096

output:

926839525

result:

ok single line: '926839525'

Test #3:

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

input:

1 1
576560149
691846236
1156187222

output:

1268406385
835582012

result:

ok 2 lines

Test #4:

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

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: 59ms
memory: 8148kb

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: 66ms
memory: 5800kb

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: 647ms
memory: 6136kb

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: 89ms
memory: 6104kb

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: 830ms
memory: 8132kb

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: -100
Time Limit Exceeded

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: