QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#211299#6638. TreelectionqLAC ✓63ms19424kbC++2315.7kb2023-10-12 14:37:242023-10-12 14:37:24

Judging History

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

  • [2023-10-12 14:37:24]
  • 评测
  • 测评结果:AC
  • 用时:63ms
  • 内存:19424kb
  • [2023-10-12 14:37:24]
  • 提交

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,fa[N];
	int siz[N],tick[N],up[N];
	bool check(int w){
		memset(tick+1,0,sizeof(tick[0])*n);
		for(int i=2;i<=n;++i) ++tick[fa[i]];
		for(int i=n;i;--i) if(tick[i]>w)
			tick[fa[i]]+=(up[i]=tick[i]-w);
		return tick[1]<=w;
	}
	void _main_(void){
		for(int T=lq.read<int>();T--;){
			lq.read(n);
			for(int i=2;i<=n;++i) lq.read(fa[i]);
			memset(siz+1,0,sizeof(siz[0])*n);
			for(int i=n;i;--i) siz[fa[i]]+=siz[i]+1;
			int l=1,r=n;
			for(int mid;l<r;)
				if(!check(mid=(l+r)>>1)) l=mid+1;
				else r=mid;
			memset(up+1,0,sizeof(up[0])*n);
			check(l-1);
			for(int i=2;i<=n;++i) Base_Tools::chkmin(up[i],up[fa[i]]);
			for(int i=1;i<=n;++i)
				if(siz[i]>l||(siz[i]==l&&up[1]<=1&&up[i]>=1)) lq.write('1');
				else lq.write('0');
			lq.writeln();
		}
		return;
	}
}
signed main(){
	return MAIN::_main_(),0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
4
1 2 3
5
1 1 2 2

output:

1100
10000

result:

ok 2 lines

Test #2:

score: 0
Accepted
time: 26ms
memory: 10276kb

input:

10
100000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 10 lines

Test #3:

score: 0
Accepted
time: 31ms
memory: 19364kb

input:

1
1000000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok single line: '111111111111111111111111111111...0000000000000000000000000000000'

Test #4:

score: 0
Accepted
time: 39ms
memory: 19332kb

input:

1
1000000
1 2 2 3 5 1 7 3 9 8 4 11 9 6 10 12 10 13 16 18 14 16 7 24 23 21 14 8 26 27 17 21 33 24 20 17 5 34 29 34 37 20 12 22 39 44 33 37 32 27 31 25 30 46 39 26 53 4 11 55 41 29 6 22 32 36 52 57 65 38 59 67 51 56 30 61 36 64 62 19 51 63 53 83 38 75 31 41 49 43 60 18 62 67 91 81 44 25 55 98 86 64 46...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok single line: '111111111111111111111111111111...0000000000000000000000000000000'

Test #5:

score: 0
Accepted
time: 19ms
memory: 12300kb

input:

65764
13
1 1 1 1 1 1 1 1 2 10 10 11
11
1 1 2 2 2 4 4 4 5 10
14
1 2 2 3 3 3 4 4 5 6 10 12 13
14
1 2 2 3 3 3 4 5 5 6 6 7 8
13
1 2 2 3 3 4 5 5 5 6 8 12
13
1 1 1 2 2 3 5 7 7 7 9 9
12
1 1 1 2 2 3 5 7 7 9 10
14
1 1 2 2 3 4 5 6 7 7 8 12 12
14
1 2 3 4 4 5 5 5 7 7 7 10 13
14
1 1 1 1 1 2 2 2 3 10 10 10 11
13
...

output:

1000000000000
11000000000
11101000010000
11100000000000
1110100000000
1010001000000
101000100000
11011001000000
11111010000000
10000000000000
1111010000000
111000100010000
111010001000
11000000000000
11100000000000
11001001000000
11000000000000
11111000000000
110011000000
1010000100000
1100111010000...

result:

ok 65764 lines

Test #6:

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

input:

1
1000000
1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 49 50 50 51 51 52...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok single line: '111111111111111111111111111111...0000000000000000000000000000000'

Test #7:

score: 0
Accepted
time: 27ms
memory: 19284kb

input:

1
1000000
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 10...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok single line: '111111111111111111111111111111...1111111111111111111111111111100'

Test #8:

score: 0
Accepted
time: 63ms
memory: 19424kb

input:

1
1000000
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

output:

100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

result:

ok single line: '100000000000000000000000000000...0000000000000000000000000000000'

Test #9:

score: 0
Accepted
time: 24ms
memory: 9840kb

input:

100
10000
1 1 2 4 1 4 4 5 6 6 1 1 10 13 3 7 7 16 11 2 15 2 19 21 5 6 8 20 12 10 9 28 14 24 30 1 8 11 1 16 34 4 10 13 25 16 6 11 16 11 2 40 1 47 24 15 29 35 21 49 8 33 26 54 46 52 48 32 54 56 11 55 7 28 30 20 4 7 58 61 65 77 65 21 82 9 22 29 3 19 3 59 26 90 48 21 89 86 95 12 98 43 30 21 59 56 43 37 6...

output:

111111111111111111111111111111111111111111101111111111111111111111111111111111111111111011111111111111111110101101111111110110101101111111111111111111111111111011011111111111111101111011110111111101011111101101111110111111011110111110011110111011001111111011110111000100010110111110101011111110110110...

result:

ok 100 lines

Test #10:

score: 0
Accepted
time: 32ms
memory: 12320kb

input:

10
100000
1 1 2 2 5 3 2 6 6 5 9 11 11 5 12 9 10 10 4 7 17 8 13 14 3 12 21 22 3 4 31 12 15 25 27 7 27 11 39 37 27 34 18 14 4 42 47 24 47 39 50 28 46 53 16 15 57 20 7 58 57 25 6 58 36 63 49 46 24 59 19 57 63 24 31 54 16 75 58 26 37 50 10 77 51 54 13 42 22 21 48 71 65 34 34 89 89 67 19 74 30 49 70 60 1...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 10 lines

Test #11:

score: 0
Accepted
time: 45ms
memory: 19280kb

input:

1
1000000
1 2 3 3 1 4 4 8 8 9 8 7 3 6 14 5 14 16 14 12 21 19 18 22 17 20 22 28 4 13 30 15 20 5 18 2 6 7 29 16 39 2 26 21 25 12 38 15 6 39 45 13 17 21 23 27 57 48 11 23 47 23 45 29 59 26 11 57 40 69 48 71 12 58 38 76 32 49 10 71 44 67 20 69 35 64 44 51 77 48 30 41 91 73 78 90 97 5 65 54 16 31 17 81 6...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok single line: '111111111111111111111111111111...0000000000000000000000000000000'

Test #12:

score: 0
Accepted
time: 18ms
memory: 9916kb

input:

100
10000
1 2 2 4 1 5 7 4 6 2 6 10 11 13 14 3 17 4 8 18 8 7 16 12 12 20 27 27 21 12 21 25 19 32 30 33 13 21 16 30 7 36 25 13 11 6 40 14 45 40 14 39 26 3 48 56 35 49 38 31 58 56 10 51 39 59 46 26 59 55 51 44 63 16 23 15 32 50 59 43 67 57 41 30 10 72 60 17 19 41 22 78 73 29 33 27 74 57 65 100 36 68 81...

output:

111111111111111111111111111111111111111111111111111111111111101111111111111111111111111111111111111111111111111111111111111111111111111111111101111110111111111111111111111011111111111111111111111110111101110111110111111111111111010111111111111001111111111111111111111101101111111111111101111011111011...

result:

ok 100 lines

Test #13:

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

input:

10
100000
1 1 3 3 4 3 1 2 8 10 7 6 10 12 2 2 14 10 13 10 16 9 15 21 23 18 23 27 3 9 9 5 25 29 11 32 5 38 19 9 34 21 38 15 39 34 24 33 25 44 19 15 22 25 38 18 5 35 8 50 19 15 4 16 21 50 32 50 12 29 68 27 13 49 54 18 62 45 30 37 79 7 82 32 70 79 27 78 41 33 43 17 13 2 82 44 21 29 63 27 101 96 97 50 35...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111101111111...

result:

ok 10 lines

Test #14:

score: 0
Accepted
time: 43ms
memory: 19340kb

input:

1
1000000
1 1 2 4 4 4 6 3 3 6 3 12 11 2 7 12 6 4 1 20 13 16 6 11 25 19 25 21 22 3 21 25 29 30 13 20 12 28 16 37 20 17 16 22 40 2 36 17 43 31 21 38 27 48 50 25 22 26 17 24 49 11 51 47 47 29 31 15 24 68 29 50 48 17 59 47 76 69 9 50 44 41 29 21 36 72 78 40 70 61 13 14 13 85 24 20 93 80 67 8 96 73 86 9 ...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok single line: '111111111111111111111111111111...0000000000000000000000000000000'

Test #15:

score: 0
Accepted
time: 26ms
memory: 9844kb

input:

100
10000
1 2 1 2 3 2 6 5 6 7 7 4 7 11 8 6 15 10 8 1 4 5 10 7 16 11 20 27 19 1 3 8 30 22 18 29 27 29 21 25 12 29 30 24 5 8 28 16 39 43 1 2 53 43 21 36 41 37 41 45 4 4 49 56 49 39 21 27 58 64 53 58 57 57 31 32 56 46 17 8 29 8 3 20 4 29 72 67 24 74 51 52 34 92 75 78 13 3 15 37 89 58 31 54 28 71 103 88...

output:

111111111111111111111111111111111111111011111111101111111111111111111011111011111111111111011111111111110111111111101011111111111011111111111101111111000111100111010111111101010101111110111011100111111101101111111110011111111111111111111101010101111100010111111111100011011010001110110111111101111101...

result:

ok 100 lines

Test #16:

score: 0
Accepted
time: 36ms
memory: 17964kb

input:

2
500000
1 2 3 2 5 4 7 1 8 9 10 7 10 9 12 4 5 16 3 11 6 11 13 21 25 6 16 13 15 19 28 19 30 33 26 32 34 26 21 14 39 41 27 40 39 12 37 17 31 27 37 18 32 31 28 44 34 44 23 24 41 52 57 29 45 54 48 18 47 52 70 71 49 24 48 54 51 29 66 61 60 82 70 23 79 64 50 60 45 17 63 47 25 86 57 51 14 40 98 30 35 59 35...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 2 lines

Test #17:

score: 0
Accepted
time: 22ms
memory: 14092kb

input:

10
100000
1 2 2 3 3 6 1 4 9 8 9 7 11 7 4 13 5 6 10 8 19 15 21 14 19 22 17 28 21 25 29 12 10 20 27 24 33 22 25 26 5 18 36 28 18 14 42 35 47 34 27 43 39 40 46 38 24 42 57 29 47 36 54 61 59 31 62 41 30 53 65 23 45 49 71 72 73 52 48 61 57 37 13 31 40 15 17 77 20 75 48 67 35 33 49 77 89 46 65 56 34 32 95...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 10 lines

Test #18:

score: 0
Accepted
time: 17ms
memory: 9888kb

input:

100
10000
1 1 2 4 4 3 7 8 6 5 10 5 13 10 15 16 11 14 8 11 7 6 22 9 17 2 9 13 16 27 15 20 30 21 24 35 29 34 37 40 28 40 19 20 32 41 28 45 17 21 32 47 45 31 37 35 27 53 26 19 44 58 38 49 59 24 36 42 62 57 12 18 48 31 18 62 46 46 63 33 36 64 59 60 66 79 58 86 77 54 76 86 82 63 43 53 87 76 47 77 64 30 7...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...

result:

ok 100 lines

Test #19:

score: 0
Accepted
time: 55ms
memory: 19396kb

input:

1
1000000
1 2 3 1 1 6 6 7 7 5 5 12 10 11 6 16 4 7 5 17 14 19 6 1 7 16 9 15 9 21 30 25 6 7 34 32 32 26 25 19 29 1 42 44 32 39 7 43 4 22 28 22 52 25 38 43 52 17 11 9 21 36 28 54 13 17 53 52 62 69 9 3 37 69 47 8 44 9 19 5 44 21 18 14 15 22 19 71 60 25 6 88 29 94 4 30 29 88 74 55 63 31 21 9 23 4 80 35 1...

output:

111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111111111111111111110111111111111111111111111111111111111111111111111111111...

result:

ok single line: '111111111111111111111111111111...0000000000000000000000000000000'