QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#141986#6376. LaLa and LampqLAC ✓9ms8812kbC++1424.9kb2023-08-18 09:28:292023-08-18 09:28:32

Judging History

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

  • [2023-08-18 09:28:32]
  • 评测
  • 测评结果:AC
  • 用时:9ms
  • 内存:8812kb
  • [2023-08-18 09:28:29]
  • 提交

answer

#include<cstdio>
#include<cstdlib>
#include<utility>
#include<type_traits>
/**
 * 宗旨:
 * 不排斥STL,不追求最小的常数,力争通用化,不过度检查错误
 * ----------------------------------------------------------------------------------
 * 匿名的namespace一般是define
 * Base_Tools是常用板子
 * Math_Tools是偏数学的板子
 * IO是读写优化
 * rel_ops其实跟标准库的基本一个用法,但是模板参传了俩
 * 现在这份缺省源已经缩减为18kb了……
 * (慢得要死)
 * 经过了删减,只保留了觉得写得还行的板子
 * 添加了一些内建函数有关,同时std::enable_if限制了一些函数
 * 然后发现auto的泛型就是默认上抬……算了就这样。
 * 泛型auto……LQ你越来越离谱了。
 * “你是写开发的吗?”啊也许以后是写库的
 * todo:
 * modInt更好用。
 * frac写好。
 * learn Poly
 * 修锅基排
 * 重写IO,判EOF
*/
namespace QL{
	namespace{
	#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 memset __builtin_memset
	#define memcpy __builtin_memcpy
	#define strlen __builtin_strlen
	#define strcmp __builtin_strcmp
	#define fwrite __builtin_fwrite
	#define putchar __builtin_putchar
	#define fputc __builtin_fputc
	#define log2 __builtin_log2
	#define log __builtin_log
#ifndef likely
	#define likely(x) __builtin_expect(!!(x),1)
#endif
#ifndef unlikely
	#define unlikely(x) __builtin_expect(!!(x),0)
#endif
	}
	namespace Base_Tools{
#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
		using ll=long long;
		using ull=unsigned long long;
		using ui=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
		template<typename _Tp1,typename _Tp2>
		auto min(_Tp1 x,_Tp2 y){
			return x<y?x:y;
		}
		template<typename _Tp,typename ...Args>
		auto min(_Tp x,Args ...args){
			return min(x,min(args...));
		}
		template<typename _Tp1,typename _Tp2>
		auto max(_Tp1 x,_Tp2 y){
			return y<x?x:y;
		}
		template<typename _Tp,typename ...Args>
		auto max(_Tp x,Args ...args){
			return max(x,max(args...));
		}
		template<typename _Tp1,typename _Tp2>
		bool chkmin(_Tp1 &x,_Tp2 y){
			return y<x?(x=y,true):false;
		}
		template<typename _Tp1,typename _Tp2,typename...Args>
		bool chkmin(_Tp1 &x,_Tp2 y,Args ...args){
			return chkmin(x,y)|chkmin(x,args...);
		}
		template<typename _Tp1,typename _Tp2>
		bool chkmax(_Tp1 &x,_Tp2 y){
			return x<y?(x=y,true):false;
		}
		template<typename _Tp1,typename _Tp2,typename...Args>
		bool chkmax(_Tp1 &x,_Tp2 y,Args ...args){
			return chkmax(x,y)|chkmax(x,args...);
		}
		template<typename _Tp>
		void swap(_Tp &x,_Tp &y){
			static _Tp tmp;
			tmp=x,x=y,y=tmp;
		}
		template<>
		void swap(int &x,int &y){
			x!=y&&(x^=y^=x^=y);
		}
		template<typename _Tp>
		void swap(_Tp *&x,_Tp *&y){
			static _Tp *tmp;
			tmp=x,x=y,y=tmp;
		}
		template<typename _Tp>
		class has_member_swap{
		private:
			template<typename T>
			static auto Check(int)->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>(0)),std::true_type>::value  };
		};
		template<typename _Tp>
		void swap(_Tp &x,_Tp &y,typename std::enable_if<has_member_swap<_Tp>::value,void>::type* =nullptr){
			x.swap(y);
		}
		template<typename _Tp>
		const _Tp abs(const _Tp&x){
			return x<0?-x:x;
		}
	}
	/*
	gcd和lcm会把非整数的gcd当作1
	Math_Tools_Base是实现,有些地方接口改了一下,就多套了一层
	*/
	namespace Math_Tools{
		namespace Math_Tools_base{
			template<typename _Tp,typename _Used>
			_Tp qpow(Base_Tools::ll x,_Used p,_Tp mod){
				_Tp ret=1;
				for(;p;p>>=1,x=x*x%mod) if(p&1) ret=ret*x%mod;
				return ret;
			}
		}
		template<typename _Tp,typename _Used>
		_Tp qpow(_Tp x,_Used p,_Tp mod){
			return Math_Tools_base::qpow(x,p,mod);
		}
		template<typename _Tp>
		_Tp inv(_Tp x,_Tp mod){
			return Math_Tools_base::qpow(x,mod-2,mod);
		}
		template<typename _Tp>
		auto gcd(_Tp a,_Tp b,typename std::enable_if<std::is_integral<_Tp>::value,void>::type* =nullptr){
			return b?gcd(b,a%b):a;
		}
		template<typename _Tp>
		auto gcd(_Tp a,_Tp b,typename std::enable_if<std::is_floating_point<_Tp>::value,void>::type* =nullptr){
			return 1;
		}
		template<typename _Tp>
		auto lcm(_Tp a,_Tp b){
			return a/gcd(a,b)*b;
	}
	}
	/**
	 * 本实现的亮点是支持不定模数(不用遍历地进行初始化)
	 * 需要实现一个类,重载const类型的()运算符返回模数
	 * 实现可参考QL::ModNumber::Moder
	 * 模数有问题可以重载inv
	 * 其他的不知道了,似乎不是很快,要卡常的可以套约减器
	 * (用这玩意儿也就图个方便)
	 * upd:塞进去了个barrett约减,更慢了(乐
	 * 跑不过编译器优化,它是蒙哥马利吗……
	 */
	namespace ModNumber{
		using QL::Base_Tools::ll;
		using QL::Base_Tools::ulll;
		template<typename _Tp>
		struct Barrett{
			_Tp mod;
			ulll used;
			Barrett(){}
			Barrett(_Tp _mod):mod{_mod},used{(ulll(1)<<63)/mod}{}
			_Tp calc(ll x){
				return (x=x-mod*((x*used)>>63))<mod?x:x-mod;
			}
		};
		template<typename _Tp>
		struct Moder{
			template<typename _Tp_>
			void chk_val(_Tp_ &val)const{
				val<0?(val+=getmod()):(val<getmod()?0:val-=getmod());
			}
			virtual const _Tp getmod(void)const{
				return _Tp(998244353);
			}
			virtual const _Tp operator()(void)const{
				return getmod();
			}
			virtual const _Tp calc(ll x)const{
				return x%getmod();
			}
			template<typename _Tp1,typename _Tp2>
			_Tp plus(const _Tp1 &x,const _Tp2 &y)const{
				return calc(x+y);
			}
			template<typename _Tp1,typename _Tp2>
			_Tp mul(const _Tp1 &x,const _Tp2 &y)const{
				return calc(ll(x)*y);
			}
			_Tp qpow(ll a,int x)const{
				_Tp ret=1;
				for(;x;x>>=1,a=calc(a*a)) if(x&1) ret=calc(ret*a);
				return ret;
			}
			template<typename _Tp_>
			_Tp inv(const _Tp_ &x)const{
				return qpow(x,getmod()-2);
			}
		};
		template<typename _Moder>
		class modInt{
		protected:
			static _Moder mod;
			int v;
		public:
			modInt():v{}{}
			template<typename _Tp_>
			modInt(const _Tp_ &_v):v(_v%mod()){mod.chk_val(v);}
			template<typename _Tp_>
			explicit operator _Tp_()const{
				return _Tp_(v);
			}
			modInt operator-()const{
				return modInt(mod()-v);
			}
			modInt operator+(const modInt &y)const{
				return mod.plus(v,y.v);
			}
			modInt operator-(const modInt &y)const{
				return *this+(-y);
			}
			modInt operator*(const modInt &y)const{
				return mod.mul(v,y.v);
			}
			modInt operator/(const modInt &y)const{
				return mod.mul(v,mod.inv(y.v));
			}
			template<typename _Tp_>
			modInt operator^(const modInt<_Tp_> &y)const{
				return mod.qpow(v,int(y));
			}
			template<typename _Tp_>
			friend modInt operator+(const _Tp_ &x,const modInt &y){
				return mod.plus(x,y.v);
			}
			template<typename _Tp_>
			friend modInt operator+(const modInt &x,const _Tp_ &y){
				return mod.plus(x.v,y);
			}
			template<typename _Tp_>
			friend modInt operator-(const _Tp_ &x,const modInt &y){
				return x+(-y);
			}
			template<typename _Tp_>
			friend modInt operator-(const modInt &x,const _Tp_ &y){
				return x+(-y);
			}
			template<typename _Tp_>
			friend modInt operator*(const _Tp_ &x,const modInt &y){
				return mod.mul(x,y.v);
			}
			template<typename _Tp_>
			friend modInt operator*(const modInt &x,const _Tp_ &y){
				return mod.mul(x.v,y);
			}
			template<typename _Tp_>
			friend modInt operator/(const _Tp_ &x,const modInt &y){
				return mod.mul(x,mod.inv(y.v));
			}
			template<typename _Tp_>
			friend modInt operator/(const modInt &x,const _Tp_ &y){
				return mod.mul(x.v,mod.inv(y));
			}
			template<typename _Tp_>
			friend modInt operator^(const modInt &x,const _Tp_ &y){
				return mod.qpow(x.v,y);
			}
			template<typename _Tp_>
			friend bool operator<(const _Tp_ &x,const modInt &y){
				return x<y.v;
			}
			template<typename _Tp_>
			bool operator<(const _Tp_ &y)const{
				return v<y;
			}
			template<typename _Tp_>
			friend bool operator==(const _Tp_ &x,const modInt &y){
				return x==y.v;
			}
			template<typename _Tp_>
			bool operator==(const _Tp_ &y)const{
				return v==y;
			}
			modInt &operator++(){
				mod.chk_val(++v);
				return *this;
			}
			modInt operator++(int){
				modInt ret=*this;
				mod.chk_val(++v);
				return ret;
			}
			modInt &operator--(){
				mod.chk_val(--v);
				return *this;
			}
			modInt operator--(int){
				modInt ret=*this;
				mod.chk_val(--v);
				return ret;
			}
		};
		template<typename _Moder>
		_Moder modInt<_Moder>::mod;
	}
	/**
	 * 一个不成型的东西
	 * 日后补全
	 */
	namespace FracNumber{
		using QL::Math_Tools::lcm;
		using QL::Math_Tools::gcd;
		template<typename _Tp>
		class frac{
		protected:
			_Tp x,y;
			void chk_self(){
				_Tp _gcd_=gcd(x,y);
				if(_gcd_!=1) x/=_gcd_,y/=_gcd_;
			}
		public:
			frac():x{},y{}{}
			template<typename T>
			frac(T num,typename std::enable_if<std::is_integral<T>::value,void>::type* =nullptr):x(num),y(1){}
			template<typename T>
			frac(T _x,T _y,typename std::enable_if<std::is_integral<T>::value,void>::type* =nullptr):x(_x),y(_y){chk_self();}
			template<typename T>
			explicit operator T()const{
				return T(x)/y;
			}
			template<typename T>
			bool operator<(const frac<T> &it)const{
				auto _lcm_=lcm(y,it.y);
				return x*(_lcm_/y)<it.x*(_lcm_/it.y);
			}
		};
	}
	/**
	 * 多项式,占坑
	 * 以后会尽量补全的
	 */
	namespace Poly_Tools{
		/**
		 * 暴力乘法
		 */
		template<typename _Tp>
		class Poly{
		protected:
			_Tp *p;
			int n;
		public:
			int length(void)const{return n;}
			Poly():p{},n{}{}
			Poly(const int &_n):p{new _Tp[(n=_n)+1]{}}{}
			Poly(const std::initializer_list<_Tp> &L){
				p=new _Tp[L.size()+1];
				n=-1;
				for(auto it:L) p[++n]=it;
			}
			Poly(const Poly &it):n{it.n}{
				for(int i=0;i<=n;++i) p[i]=it[i];
			}
			_Tp &operator[](const int &x){
				if(x<0||x>n) std::exit(114514);
				return p[x];
			}
			const _Tp &operator[](const int &x)const{
				if(x<0||x>n) std::exit(114514);
				return p[x];
			}
			Poly operator*(const Poly &it)const{
				Poly ret(n+it.n);
				for(int i=0;i<=n;++i)
					for(int j=0;j<=it.n;++j)
						ret[i+j]=ret[i+j]+p[i]*it[j];
				return ret;
			}
		};
	}
	namespace rel_ops{
		namespace Calc{
			template<typename _Tp1,typename _Tp2>
			_Tp1 operator+=(_Tp1 &lhs,const _Tp2 &rhs){
				return lhs=(lhs+rhs);
			}
			template<typename _Tp1,typename _Tp2>
			_Tp1 operator-=(_Tp1 &lhs,const _Tp2 &rhs){
				return lhs=(lhs-rhs);
			}
			template<typename _Tp1,typename _Tp2>
			_Tp1 operator*=(_Tp1 &lhs,const _Tp2 &rhs){
				return lhs=(lhs*rhs);
			}
			template<typename _Tp1,typename _Tp2>
			_Tp1 operator/=(_Tp1 &lhs,const _Tp2 &rhs){
				return lhs=(lhs/rhs);
			}
			template<typename _Tp1,typename _Tp2>
			_Tp1 operator%=(_Tp1 &lhs,const _Tp2 &rhs){
				return lhs=(lhs%rhs);
			}
			template<typename _Tp1,typename _Tp2>
			_Tp1 operator&=(_Tp1 &lhs,const _Tp2 &rhs){
				return lhs=(lhs&rhs);
			}
			template<typename _Tp1,typename _Tp2>
			_Tp1 operator|=(_Tp1 &lhs,const _Tp2 &rhs){
				return lhs=(lhs|rhs);
			}
			template<typename _Tp1,typename _Tp2>
			_Tp1 operator^=(_Tp1 &lhs,const _Tp2 &rhs){
				return lhs=(lhs^rhs);
			}
		}
		namespace Compare{
			template<typename _Tp1,typename _Tp2>
			bool operator!=(const _Tp1 &lhs,const _Tp2 &rhs){
				return !(lhs==rhs);
			}
			template<typename _Tp1,typename _Tp2>
			bool operator<=(const _Tp1 &lhs,const _Tp2 &rhs){
				return (lhs==rhs)||(lhs<rhs);
			}
			template<typename _Tp1,typename _Tp2>
			bool operator>(const _Tp1 &lhs,const _Tp2 &rhs){
				return !((lhs==rhs)||(lhs<rhs));
			}
			template<typename _Tp1,typename _Tp2>
			bool operator>=(const _Tp1 &lhs,const _Tp2 &rhs){
				return !(lhs<rhs);
			}
		}
	}
	/**
	 * 字符串的工具
	 */
	namespace String_Tools{
		namespace SA{
			template<int M=128,int N>
			void calc_sa(char (&str)[N],int sa[],int rk[],int n){
				int m=M-1;
				static int cnt[N<M?M:N],id[N],oldrk[N<<1],key[N];
				for(int i=1;i<=n;++i) ++cnt[rk[i]=str[i]];
				for(int i=1;i<=m;++i) cnt[i]+=cnt[i-1];
				for(int i=n;i;--i) sa[cnt[rk[i]]--]=i;
				for(int k=1,p;;k<<=1,m=p){
					p=0;
					for(int i=n;i>n-k;--i) id[++p]=i;
					for(int i=1;i<=n;++i) if(sa[i]>k) id[++p]=sa[i]-k;
					memset(cnt,0,sizeof(int)*(m+1));
					for(int i=1;i<=n;++i) ++cnt[key[i]=rk[id[i]]];
					for(int i=1;i<=m;++i) cnt[i]+=cnt[i-1];
					for(int i=n;i;--i) sa[cnt[key[i]]--]=id[i];
					memcpy(oldrk,rk,sizeof(int)*(n+1));
					p=0;
					for(int i=1;i<=n;++i){
						static auto cmp=[&k](int x,int y){
							return oldrk[x]==oldrk[y]&&oldrk[x+k]==oldrk[y+k];
						};
						rk[sa[i]]=cmp(sa[i],sa[i-1])?p:++p;
					}
					if(p==n) return;
				}
			}
			template<int N>
			void calc_height(char (&str)[N],int sa[],int rk[],int height[],int n){
				for(int i=1,k=0;i<=n;++i){
					if(!rk[i]) continue;
					k&&--k;
					for(;str[i+k]==str[sa[rk[i]-1]+k];++k);
					height[rk[i]]=k;
				}
			}
		}
	}
	/**
	 * 占坑
	 */
	namespace Data_Structure{}
	namespace Algorithm{
		using QL::Base_Tools::swap;
		template<typename _Tp>
		void radix_sort(_Tp *x,int n,typename std::enable_if<std::is_integral<_Tp>::value,void>::type* =nullptr){
			static const int mask=(1<<8)-1;
			static int *cnt=new int[mask+1],*y=new int[n+5];
			for(int k=0;k<32;k+=8){
				for(int i=0;i<=mask;++i) cnt[i]=0;
				for(int i=1;i<=n;++i) ++cnt[(x[i]>>k)&mask];
				for(int sum=0,i=0;i<=mask;++i)
					sum+=cnt[i],cnt[i]=sum-cnt[i];
				for(int i=1;i<=n;++i) y[++cnt[(x[i]>>k)&mask]]=x[i];
				swap(x,y);
			}
		}
		template<typename _Tp,typename _Turn>
		void radix_sort(_Tp *x,int n,_Turn turn){
			static const int mask=(1<<8)-1;
			static int *cnt=new int[mask+1],*y=new int[n+5];
			for(int k=0;k<32;k+=8){
				for(int i=0;i<=mask;++i) cnt[i]=0;
				for(int i=1;i<=n;++i) ++cnt[(turn(x[i])>>k)&mask];
				for(int sum=0,i=0;i<=mask;++i)
					sum+=cnt[i],cnt[i]=sum-cnt[i];
				for(int i=1;i<=n;++i) y[++cnt[(turn(x[i])>>k)&mask]]=x[i];
				swap(x,y);
			}
		}
		template<typename _Tp>
		void radix_sort(_Tp *x,int n,int (*turn)(_Tp)){
			static const int mask=(1<<8)-1;
			static int *cnt=new int[mask+1],*y=new int[n+5];
			for(int k=0;k<32;k+=8){
				for(int i=0;i<=mask;++i) cnt[i]=0;
				for(int i=1;i<=n;++i) ++cnt[(turn(x[i])>>k)&mask];
				for(int sum=0,i=0;i<=mask;++i)
					sum+=cnt[i],cnt[i]=sum-cnt[i];
				for(int i=1;i<=n;++i) y[++cnt[(turn(x[i])>>k)&mask]]=x[i];
				swap(x,y);
			}
		}
		template<typename _Iterator>
		void reverse(_Iterator _st,_Iterator _ed){
			--_ed;
			for(;_st!=_ed;++_st,--_ed) swap(_st,_ed);
		}
	}
	namespace Error{
		void make_re(int _seed_=114514){
			std::exit(_seed_);
		}
#ifndef assert
		bool assert(bool x,const char *reason){
			if(unlikely(!x)){
				std::fputs(reason,stderr);
				std::fputs(reason,stdout);
				make_re();
			}
			return false;
		}
		bool assert(bool x,char *reason){
			return (x,reinterpret_cast<const char *>(reason));
		}
		bool assert(bool x){
			if(unlikely(!x)){
				std::fputs("Assert: RE",stderr);
				std::fputs("Assert: RE",stdout);
				make_re();
			}
			return false;
		}
#endif
	}
}
namespace QL{
	namespace Base_Tools{
		template<typename _Tp>
		static constexpr std::size_t integral_length=sizeof(_Tp)*10/sizeof(int);
		bool is_space(char ch){
			return ch==' ';
		}
#if (linux||__linux__||__linux)
		bool is_eoln(char ch){
			return ch=='\n'||ch=='\r';
		}
#else
		bool is_eoln(char ch){
			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::integral_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;
		/**
		 *  -DLOCAL后能使用错误流,并关掉fread/fwrite
		 * 然而使用错误流时VScode会假CE,还不能解决
		 * 此外,这套IO跟C的一样,不是很方便扩展
		 * 正在考虑怎么改一下,大概是通过友元
		 * 扩充了浮点数的输出,借助了C库的sprintf,写得还有点丑,之后改
		 * 浮点输入写好了,同样用了读如字符串的手段,不过用了atof,会短一点(牺牲了一些精度相关)。
 		*/
		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{&QL::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{&QL::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{&QL::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{&QL::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{&QL::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(){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)=&QL::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[integral_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[integral_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我要写几个不同的参数。
			 * 之后想办法干掉,大概又是套模版。
			 */
			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=&QL::IO::IOstream::push;}
#ifdef LOCAL
			void set_err_out(){outchar=&QL::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
		};
		IOstream lq;
	}
}
namespace MAIN{
	using QL::IO::lq;
	constexpr int N=2005;
	int n;
	bool a[N][N];
	int x[N][N],y[N][N];
	bool c[3][N],chk[3][N];
	signed _main_(){
		lq.read(n);
		for(int i=1;i<=n;++i)
			for(int j=1;j<=i;++j)
				lq.read(a[i][j]);
		for(int i=2;i<n;++i)
			for(int j=2;j<i;++j)
				if(a[i][j-1]^a[i-1][j]^a[i-1][j-1]^a[i][j+1]^a[i+1][j]^a[i+1][j+1]) return lq.write("No"),0;
		lq.write("Yes");
		return 0;
	}
}
signed main(){
	return MAIN::_main_();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

6
0
00
000
0110
00100
000000

output:

Yes

result:

ok answer is YES

Test #2:

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

input:

2
0
11

output:

Yes

result:

ok answer is YES

Test #3:

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

input:

3
1
10
011

output:

Yes

result:

ok answer is YES

Test #4:

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

input:

4
1
11
101
0101

output:

No

result:

ok answer is NO

Test #5:

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

input:

5
0
11
010
0011
11100

output:

No

result:

ok answer is NO

Test #6:

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

input:

6
0
10
100
1011
00001
010101

output:

No

result:

ok answer is NO

Test #7:

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

input:

7
0
01
101
0010
11000
010100
0111101

output:

No

result:

ok answer is NO

Test #8:

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

input:

8
0
01
100
1111
10011
001010
1000010
00001101

output:

No

result:

ok answer is NO

Test #9:

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

input:

9
1
00
111
0000
11110
100011
0100101
01010001
010111101

output:

No

result:

ok answer is NO

Test #10:

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

input:

10
1
01
011
1101
01011
000111
1111000
11111111
000010010
0011001100

output:

No

result:

ok answer is NO

Test #11:

score: 0
Accepted
time: 2ms
memory: 4932kb

input:

11
1
11
001
0001
00011
111000
1101001
10100101
100111110
1000001011
11110011111

output:

No

result:

ok answer is NO

Test #12:

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

input:

12
0
01
111
0101
01110
011000
1001010
10010001
011011000
1110110101
10101101110
111100100111

output:

Yes

result:

ok answer is YES

Test #13:

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

input:

13
0
00
010
0011
11101
101000
0000011
00101011
010000100
0100100100
10001100100
011011100100
1110000011011

output:

No

result:

ok answer is NO

Test #14:

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

input:

14
0
01
111
1111
01101
011000
0101111
00001110
011011001
1110000010
00111000101
110010101011
1100100011001
11001011100011

output:

No

result:

ok answer is NO

Test #15:

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

input:

15
0
10
011
0111
10100
000011
0010100
11100010
111000001
1111001011
11111110000
000110001111
0011101111100
11001101011011
010100101111110

output:

No

result:

ok answer is NO

Test #16:

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

input:

16
0
11
101
1000
01100
100010
1101111
01110101
010001000
0000110011
10011110010
101001000101
1011011111100
11110000011011
110000010111010
0111001011100110

output:

No

result:

ok answer is NO

Test #17:

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

input:

17
0
11
110
0110
10110
110111
0110100
01001100
010111101
0101011110
01010011000
010110010101
1010111110001
01010000111000
001011110101010
0110111101110000
01001111011000101

output:

No

result:

ok answer is NO

Test #18:

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

input:

18
1
01
100
0011
00100
001011
0100100
11011011
100100101
1100100111
01100100011
010011010101
1010011000110
11010011100001
011010010101111
0100101111001100
00000101011110101
011011011101111000

output:

No

result:

ok answer is NO

Test #19:

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

input:

19
0
10
110
0011
01001
110110
1000111
10010001
100001000
1111000001
01110010000
101100100001
1100001100110
01010000101000
010101111011111
0100000100110111
00111110110001000
111110010011000001
1010011010101000101

output:

No

result:

ok answer is NO

Test #20:

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

input:

20
1
01
000
1100
01011
011010
1111001
11000001
110110000
0010101100
01010010101
000100011000
1100110111101
01011111001100
011010001011101
1111001101110111
01000001011011101
100110000110001001
0000101100011011110
01000010101001110001

output:

No

result:

ok answer is NO

Test #21:

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

input:

2
0
00

output:

Yes

result:

ok answer is YES

Test #22:

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

input:

3
1
11
010

output:

Yes

result:

ok answer is YES

Test #23:

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

input:

4
1
10
000
0100

output:

Yes

result:

ok answer is YES

Test #24:

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

input:

5
0
11
011
1100
01111

output:

No

result:

ok answer is NO

Test #25:

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

input:

6
1
00
100
1101
00101
000110

output:

No

result:

ok answer is NO

Test #26:

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

input:

7
1
10
000
1011
00011
001101
0101111

output:

Yes

result:

ok answer is YES

Test #27:

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

input:

8
1
11
101
0010
00001
011001
0110111
00100011

output:

No

result:

ok answer is NO

Test #28:

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

input:

9
1
00
010
1010
10000
000100
1001110
10000111
010000110

output:

No

result:

ok answer is NO

Test #29:

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

input:

10
0
11
101
1110
11001
100100
0011001
11111100
101111111
1000100100

output:

No

result:

ok answer is NO

Test #30:

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

input:

11
0
10
000
0111
10000
100101
1110011
00110010
000100110
1000001110
10100110001

output:

No

result:

ok answer is NO

Test #31:

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

input:

12
0
01
110
0101
01001
010110
1001000
11110111
101101110
0011011110
01000100011
110011101100

output:

No

result:

ok answer is NO

Test #32:

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

input:

13
1
11
011
0101
10110
101111
0011110
10000000
101000011
0101111010
11000110111
000000101101
1001111100111

output:

No

result:

ok answer is NO

Test #33:

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

input:

14
0
00
011
0010
01111
101010
0111010
00110101
000011111
0110110101
11011000000
111110110100
0001011100010
00011110110001

output:

No

result:

ok answer is NO

Test #34:

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

input:

15
1
11
101
1110
10110
000110
1011000
01100101
000011110
0011101000
10100000100
100100100011
0000101101100
11000111110011
010111100110010

output:

Yes

result:

ok answer is YES

Test #35:

score: 0
Accepted
time: 2ms
memory: 6852kb

input:

16
0
00
011
0111
00101
001001
0111011
11101100
111110111
0101001100
01111101110
011001100010
1111101101000
01000001111010
001011010100010
1010100000110110

output:

No

result:

ok answer is NO

Test #36:

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

input:

17
1
11
000
1110
11100
011000
1000100
00101000
010111100
1010111100
10011101010
000101101110
1010001001000
01010111111000
101111111100010
0110011111011001
00010001100110101

output:

No

result:

ok answer is NO

Test #37:

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

input:

18
1
10
100
0100
00101
011010
0101111
01000101
111110100
1011110100
01011011001
100000101000
0011010000001
01111111111000
100111100101110
1111110010101100
00001111111100101
110101111011010111

output:

No

result:

ok answer is NO

Test #38:

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

input:

19
0
00
001
1011
01111
000111
0010110
00110110
010001010
1000011101
10011111100
100100011110
0010100100101
11101010101101
101010110111101
0000101110011101
00100100000100010
001100111101011101
0100011111001011100

output:

No

result:

ok answer is NO

Test #39:

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

input:

20
1
00
000
1011
01011
001001
1101110
11110111
111101111
0011010111
00100011100
000011101100
1101111001110
10111000100110
000011111101101
1011010110101001
01001011001110110
101011000010001000
1100011010001011010
00001101111100100000

output:

No

result:

ok answer is NO

Test #40:

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

input:

2
1
01

output:

Yes

result:

ok answer is YES

Test #41:

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

input:

3
1
00
101

output:

Yes

result:

ok answer is YES

Test #42:

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

input:

4
1
01
110
0110

output:

Yes

result:

ok answer is YES

Test #43:

score: 0
Accepted
time: 2ms
memory: 4988kb

input:

5
0
00
000
1110
11100

output:

Yes

result:

ok answer is YES

Test #44:

score: 0
Accepted
time: 2ms
memory: 4928kb

input:

6
0
11
101
0101
00101
110011

output:

No

result:

ok answer is NO

Test #45:

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

input:

7
1
11
011
0110
01111
110101
1000001

output:

No

result:

ok answer is NO

Test #46:

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

input:

8
1
10
100
0010
11110
011000
1101010
11110000

output:

No

result:

ok answer is NO

Test #47:

score: 0
Accepted
time: 2ms
memory: 4992kb

input:

9
0
00
100
1101
01110
010110
0011000
00000100
100111100

output:

Yes

result:

ok answer is YES

Test #48:

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

input:

10
0
10
000
1011
10100
001110
0000101
00010010
100111101
0101100011

output:

No

result:

ok answer is NO

Test #49:

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

input:

11
1
10
100
0100
00101
110001
0000001
10001111
010010011
0101010101
00100100111

output:

No

result:

ok answer is NO

Test #50:

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

input:

12
0
00
001
1010
00110
101110
1111110
10100001
011100000
0001100011
10101100100
001101101011

output:

No

result:

ok answer is NO

Test #51:

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

input:

13
1
11
011
1111
01000
110101
1100011
11001010
000011010
0001011000
00000111010
011100001111
1011010010100

output:

No

result:

ok answer is NO

Test #52:

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

input:

14
1
00
111
0100
00001
110110
0011000
00000111
101010011
1100110100
01000001000
111000010001
0010111000110
01111000110100

output:

No

result:

ok answer is NO

Test #53:

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

input:

15
1
01
001
1100
11100
100111
1100010
11010011
000011010
0111100100
10100001101
000101111011
0001011100111
01101110110110
100010011010110

output:

No

result:

ok answer is NO

Test #54:

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

input:

16
0
00
110
1101
10011
100110
0000111
11001000
101010110
1001101010
00000010010
101100011100
1001011111111
00000000111001
010011010110101
1110100110101100

output:

No

result:

ok answer is NO

Test #55:

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

input:

17
1
01
100
0111
00001
110011
0010110
00100011
101001001
0110011101
00000110101
001101100101
0010111000101
01011101111011
100110111111001
0111100011111101
01110110100001011

output:

Yes

result:

ok answer is YES

Test #56:

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

input:

18
0
10
000
1100
11010
110111
0010010
00100110
010110001
1001100000
00000111100
010010000100
0001000001010
10111100010110
011010100101110
1000000101011110
01110100110111110
111100011110000001

output:

Yes

result:

ok answer is YES

Test #57:

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

input:

19
0
01
100
1110
11100
011000
0110001
00010000
010100010
0010110110
10001000101
101010010011
1010000110101
00010001111000
100010001110100
1000110001111010
10011011100101011
101011111100110101
1000110110001110010

output:

No

result:

ok answer is NO

Test #58:

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

input:

20
1
00
011
0101
10111
110010
0000110
00010001
000111110
0110011111
11011011101
011110100110
1101010101100
01111101000101
110101101101000
1000001100110011
10101001110000100
101111101011101011
1011011000000111101
00110011010110001000

output:

No

result:

ok answer is NO

Test #59:

score: 0
Accepted
time: 8ms
memory: 8124kb

input:

1950
1
01
100
1000
01111
111110
0011100
00100110
101010011
0110111000
10001101110
100000111101
0000010011010
11000111010100
001001101001001
1101011001110011
11010001111111000
010100100011101111
0110110000100111111
10001100110101100000
011111001010111011110
1000010010010010100011
00000111011100110100...

output:

No

result:

ok answer is NO

Test #60:

score: 0
Accepted
time: 3ms
memory: 6928kb

input:

1951
1
01
010
1111
10100
101000
1010011
11000001
101010011
0000111110
00001111100
111100000001
0100101100100
00001010001011
100101001101100
0010100011111000
10011111110111011
000100100100000101
0010010011100110000
11100001111000001001
000100011110001100001
1110110111100011001101
11000010010101110000...

output:

No

result:

ok answer is NO

Test #61:

score: 0
Accepted
time: 8ms
memory: 7780kb

input:

1952
0
10
001
0111
01011
101101
0100001
00111000
000001011
1001101100
11010100010
011100111111
0010000000101
11110110001111
011000101100101
1101011101001110
00001101100011000
000111110001001010
0110100110100010000
00101101000001011011
011100001010100110010
1010000110000000011110
11001001000101001000...

output:

Yes

result:

ok answer is YES

Test #62:

score: 0
Accepted
time: 8ms
memory: 8208kb

input:

1953
1
01
010
1110
11101
000001
0001011
01000001
111000111
1100010001
11101111110
100100100000
1001010000100
11000110011110
100000000100000
1110010010100110
10110001000100110
000110011001000011
0000110001010111000
01001000000001001000
111000001001000000100
1000111010001110001001
00000100101000100010...

output:

No

result:

ok answer is NO

Test #63:

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

input:

1954
1
11
110
1101
11011
101001
0110011
10000111
111101111
0100111111
00010011111
110000100000
1010101011110
00011110100011
001110110100110
0010100110101101
10100000110111011
100110111001101000
0111100111000110001
01110111000101111100
011100000111111100111
0000110000110100101111
00110010000100010111...

output:

No

result:

ok answer is NO

Test #64:

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

input:

1955
1
00
001
1110
11101
101110
1110110
10001010
001001101
1000010110
10110110101
100011011010
1110011010110
01010001000110
100010011101010
1011110001111111
10111001010100100
011001011100010011
0100010100110010011
00111100011100010110
110110100100010111111
0101001110110000010100
00111100000111100100...

output:

No

result:

ok answer is NO

Test #65:

score: 0
Accepted
time: 4ms
memory: 6772kb

input:

1956
1
00
010
0110
01110
011111
0000010
01000111
111001101
0100100110
00011110000
101101011101
1001111111001
10001010110000
111111111011101
1011101011111000
11100111101001101
110010010000100111
0101111001011110011
00010101111101011011
101100000010000001010
0001110100110101010110
10110100010000000010...

output:

No

result:

ok answer is NO

Test #66:

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

input:

1957
0
00
000
1001
11010
000011
1110001
11010100
001011110
0111001010
11011100011
111101001111
1001111101001
00101010100101
011100000111101
1010001011110010
01001011101101101
110000001110101100
1111101010111010000
01100111100100101001
101010010000011011011
1011000110110011000001
11000010000101100001...

output:

No

result:

ok answer is NO

Test #67:

score: 0
Accepted
time: 2ms
memory: 7040kb

input:

1958
1
00
100
0100
01100
010100
1111100
10110110
001001111
0011010110
00100001110
100101000101
0101011011011
01010011110101
100010100111101
0010001100011011
00101110011111011
011110111110110010
1110000101100110011
00111100100110101101
011110011010111010110
0000111000011001010001
00001010110111000000...

output:

No

result:

ok answer is NO

Test #68:

score: 0
Accepted
time: 3ms
memory: 6920kb

input:

1959
0
00
100
1011
10100
001011
1001010
01001001
010110000
0101000010
01010100110
001010010001
1110100000000
10001000100010
101110001100110
1010000011101111
10101100111111101
110101010000100111
1001011000001101100
10110111100011111011
110110001011000101010
1001000011010001110110
00110100111000011001...

output:

Yes

result:

ok answer is YES

Test #69:

score: 0
Accepted
time: 5ms
memory: 8156kb

input:

1960
1
11
110
0010
00101
101010
1110100
01001001
000110011
0100111000
00011010000
110011111110
1101101011100
11010000011000
010101010010001
1001011110000011
11110110110100111
101110011000010000
1001111000101111111
11110010000001011111
101110111110111100000
1110000011100101100001
00110010100111110011...

output:

Yes

result:

ok answer is YES

Test #70:

score: 0
Accepted
time: 6ms
memory: 7912kb

input:

1961
1
11
001
1010
01100
010010
0111001
10110111
001111101
1110010001
11100001111
010101101010
1010010111111
11011011101110
100110101011010
0011111110110000
11101010001101110
110111010011100000
0011011010010001001
00001111110011011001
010101010100000111101
1011101110001100001101
00001011111110110100...

output:

No

result:

ok answer is NO

Test #71:

score: 0
Accepted
time: 7ms
memory: 6820kb

input:

1962
1
11
001
0101
10011
000001
1011010
01101100
100000001
1111011010
10110010011
000100000000
1011111011000
01101001101001
100000100001010
0111011111001100
00001101001000000
101100000101011000
1001000100010010110
10000001101100001011
111101100001111001111
0100110111001001000110
01101111110111010101...

output:

No

result:

ok answer is NO

Test #72:

score: 0
Accepted
time: 3ms
memory: 8716kb

input:

1963
1
11
101
1001
01101
110101
1000110
10111110
011101111
1100110111
10000001101
011001111110
1111011011110
00011110011011
100101110000110
0110001101001011
11000010011101010
101000100110100110
0101111101110100010
00111010001100111101
011001011001000010110
1110111010111011010000
00100001010101111010...

output:

No

result:

ok answer is NO

Test #73:

score: 0
Accepted
time: 3ms
memory: 8068kb

input:

1964
1
10
000
0101
00001
101001
1111001
00100111
001100100
0011100011
10111101100
000000001100
1010000110010
10001110110001
111001101001001
1010110101000111
01110111010100101
100110100101100001
1001001100100010110
00010111100111111000
010101011100000100101
0000101100010001100000
10100100011110011101...

output:

No

result:

ok answer is NO

Test #74:

score: 0
Accepted
time: 6ms
memory: 7416kb

input:

1965
1
10
110
1001
00001
011110
0110110
01111001
101100111
0000110000
01011001110
101011000111
1010100101100
10100100011011
100001111001100
1011101100001111
11011101101100011
001110101011111010
0100011001010111011
00001010010101101110
110111100010011100011
1000110110000101010100
11001101110000101000...

output:

No

result:

ok answer is NO

Test #75:

score: 0
Accepted
time: 7ms
memory: 7948kb

input:

1966
1
00
110
0011
00111
001110
0011100
01000111
100001110
0001100011
11010111000
101100001111
1000001100001
01100101000010
000101100000101
1010111110001011
10001100101101001
100111010010101100
0110101000011011000
00010001100000110001
110100111011000011100
1100110101010110111000
11000010001001011110...

output:

No

result:

ok answer is NO

Test #76:

score: 0
Accepted
time: 6ms
memory: 8392kb

input:

1967
0
00
101
0111
01101
000111
0101101
01111001
000101110
1010000000
01111011101
111010011001
0010000010000
00111011111100
101101100100101
0111000010010111
11101100000001100
101000100100111011
0111101010010101010
00010110111110001001
010111110011000110000
1000010000101010111100
11101001101001110100...

output:

No

result:

ok answer is NO

Test #77:

score: 0
Accepted
time: 7ms
memory: 6960kb

input:

1968
1
00
111
1011
10100
101011
0011001
01001011
001100101
0010100111
01101111101
011101000000
0001100000001
10001110100000
100001100001111
0010010101110111
01001111000110100
101100001001011111
1010001100001001001
10011110101111011011
000111011100001001010
0110100001000110000001
11011011011000001000...

output:

No

result:

ok answer is NO

Test #78:

score: 0
Accepted
time: 7ms
memory: 6892kb

input:

1969
0
00
001
1100
11000
101110
1000011
10011001
000101101
0101000101
01110010101
000111001011
0010101110111
10110000001111
011111011111110
1001101100011100
10010111100100111
000100011101010001
1010110100001000010
01110011011001100100
000111000101000101000
1101010000110101001110
10110000000001110000...

output:

No

result:

ok answer is NO

Test #79:

score: 0
Accepted
time: 7ms
memory: 8760kb

input:

1970
1
10
111
1010
01110
000111
1101011
10110010
111111110
0010011000
01001010100
111111001100
1101100000011
11001010011100
101111001011100
0111100000100010
01100101100100000
111010110100100101
0101001111011010000
10001111100100111010
100111100100100010001
0110100101011010111001
11101101001011000010...

output:

No

result:

ok answer is NO

Test #80:

score: 0
Accepted
time: 3ms
memory: 7332kb

input:

1971
1
01
110
1101
00100
110101
0101000
01010010
011100111
0110100001
00001111000
101001100110
1110110100001
00000010100000
100111111011100
1001101001000100
10001001010101011
001111111110001101
0111010100110100111
00111110101011101010
011000000000100100011
0100001110111101010101
10111011101011111100...

output:

No

result:

ok answer is NO

Test #81:

score: 0
Accepted
time: 4ms
memory: 7656kb

input:

1972
0
11
011
0101
01001
110000
0000010
01100110
101010000
0100111100
10111100101
110001010111
0000011001101
00011000000111
100101110010010
1010111101000110
00110011011101111
000000101001000010
1110010110011100111
10010110000110101100
010100000010011000100
1100110011000111101011
10000010101101110110...

output:

No

result:

ok answer is NO

Test #82:

score: 0
Accepted
time: 3ms
memory: 8032kb

input:

1973
1
01
111
1100
10100
011110
0100110
11011001
111000101
0000001110
01011111011
111000010111
0011101000011
11111001111100
100110110010101
0101111000011111
10100111100101111
110011110011001011
0101110000010001000
00001000110110101101
000000111111011001010
0011100011010110000000
11010001000110111110...

output:

No

result:

ok answer is NO

Test #83:

score: 0
Accepted
time: 7ms
memory: 7740kb

input:

1974
1
11
011
1011
11010
011000
1100011
01101010
110000110
0001011110
10000010000
001101110010
0001001001000
10000000111100
001101100101011
0110110100000101
11000000101011000
111010011000011101
1111110100010010111
01110111010110000011
010011011000001010101
1010111100010000000111
11011110010110010100...

output:

No

result:

ok answer is NO

Test #84:

score: 0
Accepted
time: 5ms
memory: 6940kb

input:

1975
1
10
001
1100
11001
111001
1011011
10001100
101011000
0000001000
00110111011
010010101000
0100100100011
11111101011100
100010101011011
0000010111000011
10101100110001110
100100000110011111
0101010011111000001
01100001000010001100
101110111000011111101
1110110111101010101100
10110101011001100000...

output:

No

result:

ok answer is NO

Test #85:

score: 0
Accepted
time: 7ms
memory: 7276kb

input:

1976
0
01
010
0011
10000
110111
1000111
11011000
100011001
1101100100
00001100000
011001101001
1010110000100
11001001011110
011110111101010
1101110101111100
11110001110101110
100110000111110100
0010110010101000000
01110110110000101000
110110111111011111001
1111001010010010100101
00011001110111111100...

output:

No

result:

ok answer is NO

Test #86:

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

input:

1977
1
01
000
0100
11100
010010
1110000
00110101
110111111
0010101011
00101111101
101011010000
0001001110100
01001100111101
100111001010001
0111010010001000
00000000100111011
010001010110100011
1001100001101101100
00001001000100001101
110000011010111001110
1101101000001110110111
10101000001000010111...

output:

Yes

result:

ok answer is YES

Test #87:

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

input:

1978
1
10
000
1100
01111
001011
1000000
00111000
101000101
1010011001
10000011100
110000101111
1111001111110
11001111100111
101010010001000
1001001010000111
00111000111110101
010110110100111010
1011100010111110111
11001101010000101011
000100100111000011010
1011110001100011011001
10110111101101000100...

output:

No

result:

ok answer is NO

Test #88:

score: 0
Accepted
time: 8ms
memory: 7784kb

input:

1979
0
10
011
0111
11110
010010
1110100
00111001
001011101
0010010101
00100000101
110111011010
1101110011011
10100011100110
000111000011101
1011110000010101
10010011111111011
011110111111011000
1000111111110011110
10001010000011101101
000010001111000001011
1011011001110000111000
11101001001100001011...

output:

No

result:

ok answer is NO

Test #89:

score: 0
Accepted
time: 8ms
memory: 7804kb

input:

1980
0
01
100
1000
10000
100000
1000001
00000011
110000111
0101110001
10010011100
111101000111
1100011110001
00100001100011
101011010111000
0110101100001110
10001000001100011
100001100101000111
1000000101100001111
11111101000001100001
101111001100101000011
1110001111010011111000
10110011101000001110...

output:

Yes

result:

ok answer is YES

Test #90:

score: 0
Accepted
time: 6ms
memory: 7100kb

input:

1981
1
01
000
1010
11101
000100
1000001
10101101
110001101
0110011111
01100001010
010000001001
0000101011010
11101111100101
110100111001011
1000010000100001
10111100101100101
000001101001001100
0110010001010011101
01101100001000010110
100000100011101110111
0001011111110000000101
11001110010100110000...

output:

No

result:

ok answer is NO

Test #91:

score: 0
Accepted
time: 7ms
memory: 6932kb

input:

1982
0
10
101
1011
01001
010010
0011010
11110100
100101001
1101101100
01111100111
010100001110
1100011011100
00001101111000
011010000110000
0101101010100000
10111100001111111
110011110111000000
0000100100101000000
10010101111110111110
101001000110110111101
1100001101011001000100
11110000110000110110...

output:

No

result:

ok answer is NO

Test #92:

score: 0
Accepted
time: 3ms
memory: 7324kb

input:

1983
1
00
000
1011
11100
101011
0111101
00101000
111000010
1000111000
00110001000
100010011000
0101000011000
10100000101001
100101100000011
1101100011111111
11010111111101000
000011001100001100
0100110000111110100
01011000110111011111
001111110111111010100
0100110011001110101000
01100000101011110110...

output:

No

result:

ok answer is NO

Test #93:

score: 0
Accepted
time: 7ms
memory: 8192kb

input:

1984
1
10
001
0110
00111
111011
0000011
10001101
010010001
1010101001
11011011000
011000111010
0100000000000
10101110001010
001001101100001
1110001010110110
11111111011100111
111100011001000101
0000100100011111111
10001010101001110100
010010110111101100010
0101010001101010110001
11011011111000100010...

output:

No

result:

ok answer is NO

Test #94:

score: 0
Accepted
time: 6ms
memory: 7148kb

input:

1985
1
00
010
1011
10010
000001
1101010
11101010
001010000
1100111111
11011011000
101110100001
0000011111010
00100100111000
100101101010001
0000000010110101
11010001001011001
011110110001011010
0001000110111110010
01110001101010011001
100111111000011110100
0111101111110111111100
00010000001110110100...

output:

No

result:

ok answer is NO

Test #95:

score: 0
Accepted
time: 7ms
memory: 8296kb

input:

1986
0
11
011
0011
10010
001111
0001010
11111111
111101010
1000111110
10110010111
001011000101
0001110011111
10000100101010
110010001000001
0001000101101001
10000010011000111
010010111110011011
1010111100100100010
10100010101110101111
010110111000101001011
1101100011101101111101
00011001010111100010...

output:

No

result:

ok answer is NO

Test #96:

score: 0
Accepted
time: 2ms
memory: 7612kb

input:

1987
1
01
100
1000
10000
011110
0111101
11111011
010001000
1001101110
11110100011
010000111000
0110011110001
10001010011101
100000110111010
0111100000001011
00000101101101000
001110110110101111
1010010000000100001
10010100010011000011
111100111001011111000
1100000001111010001111
01011001100011001100...

output:

No

result:

ok answer is NO

Test #97:

score: 0
Accepted
time: 6ms
memory: 8464kb

input:

1988
1
00
111
1001
10111
101100
1101010
11011110
001111011
0110101001
11101101011
101001110000
0111011100101
01010110100010
101011010011110
1001011111000011
01000001100111000
110001110111111111
1011101111011010111
10111111010001010010
011101100111000100101
1010011000011011001001
00000110011110001100...

output:

No

result:

ok answer is NO

Test #98:

score: 0
Accepted
time: 8ms
memory: 8812kb

input:

1989
1
00
110
0100
11111
110110
0100100
01111110
000110101
0101011100
00001110001
010111010100
0111010011110
11100000001010
010101011011100
0000111101110000
00100010000101001
001101001010011010
1011111111111111101
00000101101011001100
110110001000010101110
0011011000010001101010
01000001010110111100...

output:

No

result:

ok answer is NO

Test #99:

score: 0
Accepted
time: 3ms
memory: 8204kb

input:

1990
1
00
001
1100
01000
000001
0101100
10001001
100111101
0110101010
00010000101
001011011011
0100110011001
01111100011101
000110111101010
0101011111111011
01110001111011000
000111010001100000
0101010010011101111
11110000010111110001
110111011100000110011
1011010011110001001001
01111111100101101000...

output:

No

result:

ok answer is NO

Test #100:

score: 0
Accepted
time: 5ms
memory: 8104kb

input:

1991
1
11
111
1101
01101
100010
0000001
11011110
110100010
1110101101
10001111001
011001011100
1100000000100
00111111000000
110111001000001
0000001111110101
11001100110100000
110010010110100001
1110011101111100101
01011110010101100110
100001101011111011111
1010000100000101111111
01111110110011111000...

output:

No

result:

ok answer is NO

Test #101:

score: 0
Accepted
time: 7ms
memory: 8252kb

input:

1992
0
11
111
0111
10111
001001
1110101
11110011
000000001
0000011010
00000101100
011110111111
0011101100111
10011011010111
001101001001001
1110001101110101
00001000100001100
011111010111111110
0011100001111100101
10011010111111010011
110010111011110111111
0001110011100010011001
00001000101100100101...

output:

No

result:

ok answer is NO

Test #102:

score: 0
Accepted
time: 7ms
memory: 6780kb

input:

1993
1
10
111
1100
00011
001001
1011100
11011110
011101000
1000000010
11011101011
011111100111
1000011100110
00111001100100
100111100001101
1100111110101011
11111010000000101
101101101011110101
1000111111111001110
00110011001100100110
011111100100111101001
0101010010101001111010
00001000011100111010...

output:

No

result:

ok answer is NO

Test #103:

score: 0
Accepted
time: 4ms
memory: 7216kb

input:

1994
1
10
100
0000
10110
000100
1100000
01010111
011000110
1111100101
10110100011
000100101111
1100000110111
10101000000111
111000110011001
1011100101011011
01101011100100001
111111010000101011
0011011001000111111
10101100000111101000
011000010011001000110
0000011110100100011010
11001011000100001011...

output:

No

result:

ok answer is NO

Test #104:

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

input:

1995
1
10
101
0100
01010
100110
0100000
00010101
001111010
0100000111
11010101011
000111011110
1101110100100
11100001111101
101100111000111
1001011101010001
11110000011011000
101011101100110111
1010001010011011010
00000011100011101001
110011011110100100000
0000111010010110100110
11100000110011111100...

output:

No

result:

ok answer is NO

Test #105:

score: 0
Accepted
time: 8ms
memory: 7048kb

input:

1996
0
01
110
1001
01000
110101
0001111
00000100
100010011
0100111101
10101100000
101000100101
1010010101110
11011001000111
100110001101011
0011100000110011
10010111101111100
101111111000011100
1010101110011011100
11011110011010100010
100110110110110100000
1011100111101110100101
00101000101011110101...

output:

Yes

result:

ok answer is YES

Test #106:

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

input:

1997
0
01
001
1000
10100
101100
1011101
00111110
011111000
0101110100
01001101101
110001011111
0000000111010
11100011110000
000100101100100
0110101001001101
01010110000011110
010010000010111001
0011100011000001000
01111111010010010101
110111001000110101111
0111001010010000100100
10100101100111100110...

output:

Yes

result:

ok answer is YES

Test #107:

score: 0
Accepted
time: 7ms
memory: 8076kb

input:

1998
0
00
100
1110
11111
011101
0101011
00101011
001110001
0110010111
00010011001
010001011001
0001110111011
10001001000111
101000000011010
0000100000110110
00100101010111111
101001001010010100
0100101011110101100
10000111101010100000
010000100001001111001
1101001010010110100011
11110110110011000000...

output:

No

result:

ok answer is NO

Test #108:

score: 0
Accepted
time: 5ms
memory: 6872kb

input:

1999
0
01
110
0110
11001
000110
1000110
10111000
101000100
1101000011
11101001101
100010101111
1011101101010
01011100011110
110100000001000
1110100111011010
00001010110000000
111110110100110101
0000001110001011111
10000000000101110101
110000011101100100001
0110000100111110001001
00110001010011011011...

output:

Yes

result:

ok answer is YES

Test #109:

score: 0
Accepted
time: 3ms
memory: 8160kb

input:

2000
1
10
010
0011
01111
000000
1001110
11011111
110101101
1100000110
01100110011
000010011010
0011111110100
11010110011010
001011010111000
0000011101001110
00100011000111100
111010001100101111
1111011001011001011
11110010000110011000
000101110010100100111
1110100001000100001101
00011110100011011001...

output:

No

result:

ok answer is NO