QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#310318#5446. 琪露诺的符卡交换qL100 ✓92ms4788kbC++2015.5kb2024-01-21 10:56:082024-01-21 10:56:09

Judging History

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

  • [2024-01-21 10:56:09]
  • 评测
  • 测评结果:100
  • 用时:92ms
  • 内存:4788kb
  • [2024-01-21 10:56:08]
  • 提交

answer

#include<cstdio>
#include<cstdint>

#include<array>
#include<utility>
#include<initializer_list>
#include<limits>

#include<string>
#include<vector>
#include<queue>

/**
 * Author: Cracker
 * Version: 0x02
*/
namespace Default_Source{
#ifndef _linux_
#define likely(x) __builtin_expect(!!(x),1)
#define unlikely(x) __builtin_expect(!!(x),0)
#endif
	namespace{
		template<typename T>
		constexpr T Inf{std::numeric_limits<T>::max()};
		template<typename T>
		constexpr T abs(const T&x){return x<T(0)?-x:x;}
		template<typename T>
		constexpr const T&min(const T&lhs,const T&rhs){return lhs<rhs?lhs:rhs;}
		template<typename T>
		constexpr T min(const std::initializer_list<T>&L){
			T ret=*L.begin();
			for(const T&it:L) ret=min(ret,it);
			return ret;
		}
		template<typename T>
		constexpr const T&max(const T&lhs,const T&rhs){return lhs<rhs?rhs:lhs;}
		template<typename T>
		constexpr T max(const std::initializer_list<T>&L){
			T ret=*L.begin();
			for(const T&it:L) ret=max(ret,it);
			return ret;
		}
		template<typename T>
		constexpr void swap(T&x,T&y){
			T tmp=std::move(x);
			x=std::move(y),y=std::move(tmp);
		}
	}
	namespace Bit{
		template<typename T>
		typename std::enable_if<std::is_signed<T>::value,T>::type bswap(T value){
			size_t n{(sizeof(T)<<3)-1};
			T ret{};
			for(size_t i=0,j=n-1;i<n;++i,--j) if((value>>i)&1) ret|=1<<j;
			return ret;
		}
		template<typename T>
		typename std::enable_if<std::is_unsigned<T>::value,T>::type bswap(T value){
			size_t n{sizeof(T)<<3};
			T ret{};
			for(size_t i=0,j=n-1;i<n;++i,--j) if((value>>i)&1) ret|=1<<j;
			return ret;
		}
	}
	namespace IO{
		namespace Flush{
			struct Input_Flush_Base{char getc(){return getchar();}};
			template<size_t BUFSIZE>
			class Fast_Input_Flush_Base{
			protected:
				char buf[BUFSIZE],*cur=buf;
			public:
				Fast_Input_Flush_Base(){std::fread(buf,1,BUFSIZE,stdin);}
				char getc(){return*cur++;}
			};
			template<size_t BUFSIZE>
			class Fast_Input_Flush_Safer{
			protected:
				char buf[BUFSIZE],*cur,*nil;
				bool reload(){return (nil=(cur=buf)+std::fread(buf,1,BUFSIZE,stdin))!=buf;}
			public:
				Fast_Input_Flush_Safer(){reload();}
				char getc(){return (cur!=nil||reload())?*cur++:EOF;}
			};
			struct Output_Flush_Base{void putc(char ch){putchar(ch);}};
			template<size_t BUFSIZE>
			class Fast_Output_Flush_Base{
				char buf[BUFSIZE],*cur=buf;
			public:
				~Fast_Output_Flush_Base(){std::fwrite(buf,1,cur-buf,stdout);}
				void putc(char ch){*cur++=ch;}
			};
			template<size_t BUFSIZE>
			class Fast_Output_Flush_Safer{
				char buf[BUFSIZE],*cur=buf;
				bool freeze(){return likely(cur!=buf)&&(fwrite(buf,1,cur-buf,stdout),cur=buf);}
			public:
				~Fast_Output_Flush_Safer(){freeze();}
				void putc(char ch){cur-buf==BUFSIZE&&freeze(),*cur++=ch;}
			};
		}
		template<typename _Input_Flush=Flush::Input_Flush_Base>
		class InStream{
			static _Input_Flush Input;
		public:
			template<typename T>
			typename std::enable_if<std::is_integral<T>::value,InStream>::type&operator>>(T&x){
				x=0;bool sign=false;char Ch=Input.getc();
				for(;!isdigit(Ch);Ch=Input.getc()) if(Ch=='-') sign=true;
				for(;isdigit(Ch);Ch=Input.getc()) x=x*10+(sign?-(Ch&15):(Ch&15));
				return *this;
			}
			InStream&operator>>(char*str){
				while(isspace(*str=Input.getc()));
				while(!isspace(*++str=Input.getc()));
				return *str='\0',*this;
			}
			template<typename ...Args>
			InStream&read(Args&&...args){return std::initializer_list<InStream>{*this>>args...},*this;}
			template<typename T>
			T read(){
				static T x;
				return read(x),x;
			}
		};
		template<typename _Input_Flush>
		_Input_Flush InStream<_Input_Flush>::Input;
		template<typename _Output_Flush=Flush::Output_Flush_Base>
		class OutStream{
			static _Output_Flush Output;
		public:
			template<typename T>
			typename std::enable_if<std::is_integral<T>::value,OutStream>::type&operator<<(T x){
				static char sta[114];
				int top=0;
				if(x<0){
					Output.putc('-');
					do sta[top++]=(-(x%10))|48,x/=10;
					while(x);
				}
				else
					do sta[top++]=(x%10)|48,x/=10;
					while(x);
				while(top) Output.putc(sta[--top]);
				return *this;
			}
			OutStream&operator<<(char Ch){return Output.putc(Ch),*this;}
			OutStream&operator<<(const char*Str){while(*Str) Output.putc(*Str++);return *this;}
			OutStream&operator<<(char*Str){return *this<<(static_cast<const char*>(Str));}
			template<typename ...Args>
			OutStream&write(Args...args){return std::initializer_list<OutStream>{*this<<args...},*this;}
			template<typename ...Args>
			OutStream&writeln(Args...args){return write(args...),Output.putc('\n'),*this;}
		};
		template<typename _Output_Flush>
		_Output_Flush OutStream<_Output_Flush>::Output;
	}
	namespace ModTool{
		template<typename _Tp,_Tp mod,_Tp phi=mod-1>
		struct Moder{
			static_assert(std::is_integral<_Tp>::value,"Only integers can be modulus.");
			template<typename T>
			constexpr _Tp norm(T x)const{return x<0?x%mod+mod:x%mod;}
			template<typename T>
			constexpr _Tp unorm(T x)const{return x%mod;}
			template<typename T,typename...Args>
			constexpr void plus(T&x,Args...args)const{x=norm(x),void(std::initializer_list<T>{(x=unorm(x+norm(args)))...});}
			template<typename T,typename...Args>
			constexpr void mult(T&x,Args...args)const{x=norm(x),void(std::initializer_list<T>{(x=unorm(x*norm(args)))...});}
			template<typename...Args>
			constexpr _Tp sum(Args...args)const{
				_Tp ret{0};
				return plus(ret,args...),ret;
			}
			template<typename...Args>
			constexpr _Tp prod(Args...args)const{
				_Tp ret{1};
				return mult(ret,args...),ret;
			}
			template<typename T>
			constexpr _Tp qpow(_Tp x,T pw)const{
				_Tp ret{1};
				x=norm(x);
				for(;pw;pw>>=1,x=unorm(x*x)) if(pw&1) ret=unorm(ret*x);
				return ret;
			}
			constexpr _Tp inv(_Tp x)const{return qpow(x,phi-1);}
			template<size_t N>
			constexpr auto getFac(){
				std::array<_Tp,N> Fac{};
				Fac[0]=1;
				for(size_t i=1;i<N;++i) Fac[i]=unorm(Fac[i-1]*i);
				return Fac;
			}
			template<size_t N>
			constexpr auto getInv(_Tp Fac){
				std::array<_Tp,N> Inv{};
				Inv[N-1]=inv(Fac),Inv[0]=1;
				for(size_t i=N-2;i;--i) Inv[i]=unorm(Inv[i+1]*(i+1));
				return Inv;
			}
		};
	}
	namespace DS{
		namespace Sgt{
			enum SegmentTree_Type{Single=1,Interval=2};
			template<typename Info,SegmentTree_Type _Modify,SegmentTree_Type _Query,typename Vec=std::vector<Info>>
			class SegmentTree{};
			template<typename Info,typename Vec>
			class SegmentTree<Info,Interval,Interval,Vec>{
			private:
				int st,ed;
				Vec tr;
				void build(int p,int l,int r){
					tr[p]={};
					if(l==r) return tr[p].init(l);
					int mid=(l+r)>>1;
					build(p<<1,l,mid),build(p<<1|1,mid+1,r);
					tr[p].pull(tr[p<<1],tr[p<<1|1]);
				}
				void modify(int p,int l,int r,int L,int R,const Info&V){
					if(L<=l&&r<=R) return tr[p].get(V);
					int mid=(l+r)>>1;
					tr[p].push(tr[p<<1],tr[p<<1|1]);
					if(L<=mid) modify(p<<1,l,mid,L,R,V);
					if(R>mid) modify(p<<1|1,mid+1,r,L,R,V);
					tr[p].pull(tr[p<<1],tr[p<<1|1]);
				}
				Info query(int p,int l,int r,int L,int R){
					if(L<=l&&r<=R) return tr[p];
					int mid=(l+r)>>1;
					tr[p].push(tr[p<<1],tr[p<<1|1]);
					if(L<=mid&&R>mid) return merge(query(p<<1,l,mid,L,R),query(p<<1|1,mid+1,r,L,R));
					else return L<=mid?query(p<<1,l,mid,L,R):query(p<<1|1,mid+1,r,L,R);
				}
			public:
				SegmentTree():st{},ed{},tr{}{}
				SegmentTree(int _st,int _ed):st{_st},ed{_ed}{tr.resize((ed-st+1)<<2);}
				void build(){build(1,st,ed);}
				void resize(int _st,int _ed){st=_st,ed=_ed,tr.resize((ed-st+1)<<2);}
				void modify(int L,int R,const Info&V){modify(1,st,ed,L,R,V);}
				Info query(int L,int R){return query(1,st,ed,L,R);}
				void modify(int X,const Info&V){modify(1,st,ed,X,X,V);}
				Info query(int X){return query(1,st,ed,X,X);}
			};
		}
	}
	namespace NetFlow{
		template<typename _Cap,template<typename...> typename _Vec=std::vector>
		class Maxi_Flow{
			struct edge{int ver,nxt;_Cap cap;};
			_Vec<int> Head;
			_Vec<edge> Edge;
		public:
			using edge_type=edge;
			using edge_point=int;
			edge_point edgeEnd()const{return -1;}
			edge_point edgeRev(edge_point e)const{return e^1;}
			Maxi_Flow():Head{},Edge{},Dep{}{}
			Maxi_Flow(int n):Edge{}{Head.resize(n,-1),Dep.resize(n),Que.resize(n);}
			Maxi_Flow(int n,int m){Head.resize(n,-1),Edge.reserve(m<<1),Dep.resize(n),Que.resize(n);}
			void clear(){std::fill(Head.begin(),Head.end(),-1),Edge.clear();}
			void resize(int n){Head.clear(),Head.resize(n,-1),Dep.resize(n),Que.resize(n);}
			void resize(int n,int m){Head.clear(),Head.resize(n,-1),Edge.reserve(m<<1),Dep.resize(n),Que.resize(n);}
			edge_point add(int u,int v,_Cap c){return Edge.push_back({v,Head[u],c}),Head[u]=Edge.size()-1;}
			edge_point link(int u,int v,_Cap c){return add(v,u,0),add(u,v,c);}
			const edge_point&getHead(int u)const{return Head[u];}
			const edge_type&getEdge(edge_point e)const{return Edge[e];}
			edge_type&cgEdge(edge_point e){return Edge[e];}
		private:
			_Vec<int> Dep,Cur,Que;
			bool bfs(int s,int t){
				std::fill(Dep.begin(),Dep.end(),-1);
				Que.resize(Head.size());
				static int head,tail;
				Dep[Que[head=tail=0]=s]=0;
				for(int u;head<=tail;) for(int e=Head[u=Que[head++]];~e;e=Edge[e].nxt)
					if(Edge[e].cap&&!~Dep[Edge[e].ver]) Dep[Que[++tail]=Edge[e].ver]=Dep[u]+1;
				return Dep[t]!=-1;
			}
			_Cap dfs(int u,int t,_Cap flow){
				if(u==t) return flow;
				_Cap rest=flow;
				for(int&e=Cur[u];~e&&rest;e=Edge[e].nxt)
					if(Edge[e].cap&&Dep[Edge[e].ver]==Dep[u]+1){
						_Cap cap=dfs(Edge[e].ver,t,min(rest,Edge[e].cap));
						if(cap!=0) Edge[e].cap-=cap,Edge[edgeRev(e)].cap+=cap,rest-=cap;
						else Dep[Edge[e].ver]=-1;
					}
				return flow-rest;
			}
		public:
			void output(){for(auto i=0u;i<Head.size();++i) for(int e=Head[i];~e;e=Edge[e].nxt) if(Edge[e].cap) printf("%d %d %d\n",i,Edge[e].ver,Edge[e].cap);}
			_Cap flow(int s,int t,_Cap limit=Inf<_Cap>){
				_Cap flow{};
				while(limit&&bfs(s,t)) for(Cur=Head;_Cap cap=dfs(s,t,limit);) flow+=cap,limit-=cap;
				return flow;
			}
		};
		template<typename _Cap,typename _Cost,template<typename...> typename _Vec=std::vector,template<typename...> typename _Que=std::queue>
		class Mini_Cost_Maxi_Flow{
			struct edge{int ver,nxt;_Cap cap;_Cost cost;};
			_Vec<int> Head;
			_Vec<edge> Edge;
		public:
			using edge_type=edge;
			using edge_point=int;
			edge_point edgeEnd()const{return -1;}
			edge_point edgeRev(edge_point e)const{return e^1;}
			Mini_Cost_Maxi_Flow():Head{},Edge{}{}
			Mini_Cost_Maxi_Flow(int n):Edge{}{Head.resize(n,-1),Dis.resize(n),Inq.resize(n);}
			Mini_Cost_Maxi_Flow(int n,int m){Head.resize(n,-1),Edge.reserve(m<<1),Dis.resize(n),Inq.resize(n);}
			void clear(){std::fill(Head.begin(),Head.end(),-1),Edge.clear();}
			void resize(int n){Head.clear(),Head.resize(n,-1),Dis.resize(n),Inq.resize(n);}
			void resize(int n,int m){Head.clear(),Head.resize(n,-1),Edge.reserve(m<<1),Dis.resize(n),Inq.resize(n);}
			edge_point add(int u,int v,_Cap c,_Cost w){return Edge.push_back({v,Head[u],c,w}),Head[u]=Edge.size()-1;}
			edge_point link(int u,int v,_Cap c,_Cost w){return add(v,u,0,-w),add(u,v,c,w);}
			const edge_point&getHead(int u)const{return Head[u];}
			const edge_type&getEdge(edge_point e)const{return Edge[e];}
		private:
			_Vec<int> Cur,Inq;
			_Vec<_Cost> Dis;
			bool spfa(int s,int t){
				std::fill(Dis.begin(),Dis.end(),Inf<_Cost>);
				std::fill(Inq.begin(),Inq.end(),0);
				static _Que<int> q;
				q.emplace(s),Dis[s]=0,Inq[s]=1;
				for(int u;!q.empty();){
					Inq[u=q.front()]=0,q.pop();
					for(int e=Head[u];~e;e=Edge[e].nxt)
						if(Edge[e].cap&&Dis[Edge[e].ver]>Dis[u]+Edge[e].cost)
							if(Dis[Edge[e].ver]=Dis[u]+Edge[e].cost,!Inq[Edge[e].ver]) q.emplace(Edge[e].ver),Inq[Edge[e].ver]=1;
				}
				return Dis[t]!=Inf<_Cost>;
			}
			_Cap dfs(int u,int t,_Cap flow){
				if(u==t) return flow;
				_Cap rest=flow;
				Inq[u]=1;
				for(int&e=Cur[u];~e&&rest;e=Edge[e].nxt)
					if(Edge[e].cap&&!Inq[Edge[e].ver]&&Dis[Edge[e].ver]==Dis[u]+Edge[e].cost){
						_Cap cap=dfs(Edge[e].ver,t,min(rest,Edge[e].cap));
						if(cap!=0) Edge[e].cap-=cap,Edge[edgeRev(e)].cap+=cap,rest-=cap;
						else Dis[Edge[e].ver]=Inf<_Cost>;
					}
				Inq[0]=1;
				return flow-rest;
			}
		public:
			void output(){for(auto i=0u;i<Head.size();++i) for(int e=Head[i];~e;e=Edge[e].nxt) if(Edge[e].cap) printf("%d %d %d\n",i,Edge[e].ver,Edge[e].cap);}
			std::pair<_Cap,_Cost> flow(int s,int t,_Cap limit=Inf<_Cap>){
				_Cap flow{};
				_Cost cost{};
				while(limit&&spfa(s,t)) for(Cur=Head;_Cap cap=dfs(s,t,limit);) flow+=cap,limit-=cap,cost+=cap*Dis[t];
				return {flow,cost};
			}
		};
	}
	namespace Mat{
		template<typename T>
		class Matrix{
		protected:
			int n,m;
			int**v;
			void Alloca(){
				if(n>0&&m>0){
					v=new int*[n]{};
					for(int i=0;i<n;++i) v[i]=new int[m]{};
				}
				else v=nullptr,n=m=0;
			}
			void Freeze(){
				if(n>0&&m>0){
					for(int i=0;i<n;++i) delete[] v[i];
					delete[] v;
				}
				v=nullptr,n=m=0;
			}
			void clone(int**p){for(int i=0;i<n;++i) for(int j=0;j<m;++j) v[i][j]=p[i][j];}
		public:
			int row()const{return n;}
			int col()const{return m;}
			Matrix():n{},m{},v{}{}
			Matrix(int _n,int _m):n{_n},m{_m},v{}{Alloca();}
			Matrix(int _n):n{_n},m{_n},v{}{Alloca(),init();}
			Matrix(const Matrix&it):n{it.n},m{it.m}{Alloca(),clone(it.v);}
			Matrix(Matrix&&it):Matrix{}{swap(n,it.n),swap(m,it.m),swap(v,it.v);}
			Matrix&operator=(const Matrix&it){return resize(it.n,it.m),clone(it.v),*this;}
			Matrix&operator=(Matrix&&it){return swap(n,it.n),swap(m,it.m),swap(v,it.v),*this;}
			void resize(int _n,int _m,int _v={}){
				Freeze(),n=_n,m=_m,Alloca();
				for(int i=0;i<n;++i) for(int j=0;j<m;++j) v[i][j]=_v;
			}
			T*operator[](int x){return v[x];}
			const T*operator[](int x)const{return v[x];}
			void init(){for(int i=0;i<n;++i) (*this)[i][i]=1;}
			~Matrix(){Freeze();}
			template<typename U>
			operator Matrix<U>()const{
				Matrix<U> ret(n,m);
				return ret.Alloca(),ret.clone(v),ret;
			}
		};
		template<typename Flush,typename T>
		IO::OutStream<Flush>&operator<<(IO::OutStream<Flush>&os,const Matrix<T>&it){
			for(int i=0;i<it.row();++i,os<<'\n') for(int j=0;j<it.col();++j) os<<it[i][j]<<' ';
			return os;
		}
	}
}
using namespace Default_Source;

/**
*/

constexpr int N=200;

IO::InStream<> Input;
IO::OutStream<> Output;

int n,a[N+1][N+1];
std::pair<int,int> id[N+1][N+1];
template<typename Flush>
IO::OutStream<Flush>&operator<<(IO::OutStream<Flush>&os,std::pair<int,int> p){return os<<p.first<<' '<<p.second;}
void print(){
	Output.writeln(n*(n-1)>>1);
	for(int i=1;i<=n;++i) for(int j=1;j<i;++j)
		Output<<id[i][j]<<' '<<id[j][i]<<'\n';
}
NetFlow::Maxi_Flow<int> G;

signed main(){

	for(int Test=Input.read<int>();Test;--Test){
		Input.read(n);
		for(int i=1;i<=n;++i) for(int j=1;j<=n;++j) Input.read(a[i][j]),id[i][j]={i,j};
		int s=0,t=(n<<1)+1;
		G.resize(t+1);
		for(int T=1;T<=n;++T){
			G.clear();
			for(int i=1;i<=n;++i) G.link(s,i,1),G.link(i+n,t,1);
			static int c[N+1][N+1];
			__builtin_memset(c,0,sizeof(c));
			for(int i=1;i<=n;++i) for(int j=T;j<=n;++j) if(!c[i][a[i][j]]) c[i][a[i][j]]=j,G.link(i,a[i][j]+n,1);
			if(G.flow(s,t)!=n) return 0;
			for(int i=1;i<=n;++i) for(int e=G.getHead(i);e!=G.edgeEnd();e=G.getEdge(e).nxt)
				if(!G.getEdge(e).cap){
					int k=c[i][G.getEdge(e).ver-n];
					swap(id[i][k],id[i][T]),swap(a[i][k],a[i][T]);
				}
		}
		print();
	}

	return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 3ms
memory: 4156kb

input:

7
132
96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 96 ...

output:

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

result:

ok your solution is correct.

Test #2:

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

input:

8
14
13 13 13 13 13 13 13 13 13 13 13 13 13 13
7 7 7 7 7 7 7 7 7 7 7 7 7 7
8 8 8 8 8 8 8 8 8 8 8 8 8 8
14 14 14 14 14 14 14 14 14 14 14 14 14 14
5 5 5 5 5 5 5 5 5 5 5 5 5 5
4 4 4 4 4 4 4 4 4 4 4 4 4 4
1 1 1 1 1 1 1 1 1 1 1 1 1 1
10 10 10 10 10 10 10 10 10 10 10 10 10 10
2 2 2 2 2 2 2 2 2 2 2 2 2 2
9...

output:

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

result:

ok your solution is correct.

Test #3:

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

input:

4
82
20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 10 1...

output:

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

result:

ok your solution is correct.

Test #4:

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

input:

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

output:

3
2 1 1 2
3 1 1 3
3 2 2 3
3
2 1 1 2
3 1 1 3
3 2 2 3
0
55
2 1 1 2
3 1 1 3
3 2 2 3
4 1 1 4
4 2 2 4
4 3 3 4
5 1 1 5
5 2 2 5
5 3 3 5
5 4 4 5
6 1 1 6
6 2 2 6
6 3 3 6
6 4 4 6
6 5 5 6
7 1 1 7
7 2 2 7
7 3 3 7
7 4 4 7
7 5 5 7
7 6 6 7
8 1 1 8
8 2 2 8
8 3 3 8
8 4 4 8
8 5 5 8
8 6 6 8
8 7 7 8
9 1 1 9
9 2 2 9
9 3...

result:

ok your solution is correct.

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #5:

score: 20
Accepted
time: 4ms
memory: 4208kb

input:

5
17
9 9 9 9 9 9 9 9 9 9 9 9 9 2 9 9 9
5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 6
2 2 2 2 2 2 2 2 2 2 2 2 11 2 2 2 2
4 4 4 4 4 4 10 4 4 4 4 4 4 4 4 4 4
10 10 10 10 10 10 8 10 10 10 10 10 10 10 10 10 10
12 12 12 12 12 12 12 12 12 12 12 12 14 12 12 12 12
14 14 14 14 14 14 14 14 14 14 14 12 14 14 14 14 14
16 16...

output:

136
2 17 1 2
3 13 1 3
3 2 2 3
4 7 1 4
4 2 2 4
4 3 3 4
5 7 1 5
5 2 2 5
5 3 3 5
5 4 4 5
6 13 1 6
6 2 2 6
6 3 3 6
6 4 4 6
6 5 5 6
7 12 1 7
7 2 2 7
7 3 3 7
7 4 4 1
7 5 5 1
7 6 6 7
8 3 1 8
8 2 2 8
8 1 3 8
8 4 4 8
8 5 5 8
8 6 6 8
8 7 7 8
9 2 1 9
9 1 2 9
9 3 3 9
9 4 4 9
9 5 5 9
9 6 6 9
9 7 7 9
9 8 8 9
10 9...

result:

ok your solution is correct.

Test #6:

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

input:

9
1
1
28
2 2 2 2 5 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
7 24 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7 7
13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 8 13 13 13
8 8 8 8 8 8 8 8 8 8 8 8 8 8 8 16 8 8 8 8 8 8 8 8 8 8 8 8
17 24 24 24 24 24 24 24 24 24 24 24 24...

output:

0
378
2 2 1 2
3 25 1 3
3 2 2 3
4 16 1 4
4 2 2 4
4 3 3 4
5 1 1 1
5 2 2 5
5 3 3 5
5 4 4 5
6 9 1 6
6 2 2 6
6 3 3 6
6 4 4 6
6 5 5 6
7 1 1 7
7 2 2 7
7 3 3 7
7 4 4 7
7 5 5 7
7 6 6 7
8 11 1 8
8 2 2 8
8 3 3 8
8 4 4 8
8 5 5 8
8 6 6 8
8 7 7 8
9 3 1 9
9 2 2 9
9 1 3 9
9 4 4 9
9 5 5 9
9 6 6 1
9 7 7 9
9 8 8 9
10 ...

result:

ok your solution is correct.

Test #7:

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

input:

9
22
19 19 19 19 19 19 19 19 19 10 19 19 19 19 19 19 19 19 19 19 19 19
17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 17 8
21 21 21 21 21 21 21 21 5 21 21 21 21 21 21 21 21 21 21 21 21 21
12 12 12 12 12 12 12 22 12 12 12 12 12 12 12 12 12 12 12 12 12 12
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3...

output:

231
2 22 1 2
3 9 1 3
3 2 2 3
4 8 1 4
4 2 2 4
4 3 3 4
5 21 1 5
5 2 2 5
5 3 3 5
5 4 4 5
6 3 1 6
6 2 2 6
6 1 3 6
6 4 4 6
6 5 5 6
7 2 1 7
7 1 2 7
7 3 3 7
7 4 4 7
7 5 5 7
7 6 6 7
8 21 1 8
8 2 2 8
8 3 3 8
8 4 4 1
8 5 5 8
8 6 6 8
8 7 7 8
9 1 1 9
9 2 2 9
9 3 3 1
9 4 4 9
9 5 5 9
9 6 6 9
9 7 7 9
9 8 8 9
10 13...

result:

ok your solution is correct.

Test #8:

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

input:

8
29
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 6 3 3 3 3
11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 11 3 11 11 11 11 11 11 11 11
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 23 1 1 1 1 1 1 1
20 20 20 20 20 20 20 20 20 20 20 25 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
26 26...

output:

406
2 21 1 2
3 22 1 3
3 2 2 3
4 12 1 4
4 2 2 4
4 3 3 4
5 20 1 5
5 2 2 5
5 3 3 5
5 4 4 5
6 7 1 6
6 2 2 6
6 3 3 6
6 4 4 6
6 5 5 6
7 11 1 7
7 2 2 7
7 3 3 7
7 4 4 7
7 5 5 7
7 6 6 1
8 9 1 8
8 2 2 8
8 3 3 8
8 4 4 8
8 5 5 8
8 6 6 8
8 7 7 8
9 29 1 9
9 2 2 9
9 3 3 9
9 4 4 9
9 5 5 9
9 6 6 9
9 7 7 9
9 8 8 1
10...

result:

ok your solution is correct.

Subtask #3:

score: 60
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #9:

score: 60
Accepted
time: 2ms
memory: 3932kb

input:

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

output:

0
1
2 2 1 2
3
2 3 1 1
3 3 1 2
3 1 2 1
6
2 1 1 4
3 2 1 1
3 1 2 3
4 4 1 3
4 3 2 4
4 2 3 3
10
2 5 1 3
3 2 1 4
3 3 2 4
4 4 1 2
4 3 2 1
4 1 3 1
5 4 1 5
5 5 2 2
5 2 3 4
5 1 4 5
15
2 1 1 1
3 5 1 5
3 2 2 3
4 5 1 2
4 2 2 2
4 4 3 6
5 5 1 6
5 1 2 5
5 2 3 4
5 3 4 3
6 6 1 3
6 1 2 6
6 3 3 3
6 4 4 6
6 5 5 6
21
2 3...

result:

ok your solution is correct.

Test #10:

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

input:

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

output:

0
1
2 2 1 1
3
2 1 1 1
3 2 1 3
3 1 2 3
6
2 2 1 4
3 4 1 2
3 1 2 1
4 4 1 3
4 2 2 4
4 1 3 3
10
2 1 1 4
3 5 1 2
3 4 2 3
4 5 1 1
4 1 2 5
4 2 3 3
5 1 1 5
5 4 2 2
5 5 3 2
5 2 4 3
15
2 3 1 5
3 2 1 6
3 3 2 2
4 1 1 4
4 5 2 1
4 2 3 6
5 6 1 3
5 2 2 6
5 4 3 5
5 5 4 3
6 5 1 1
6 1 2 5
6 3 3 1
6 6 4 6
6 4 5 3
21
2 5...

result:

ok your solution is correct.

Test #11:

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

input:

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

output:

0
1
2 2 1 1
3
2 1 1 2
3 3 1 1
3 1 2 3
6
2 4 1 4
3 4 1 3
3 1 2 1
4 3 1 1
4 2 2 3
4 1 3 2
10
2 4 1 3
3 4 1 1
3 1 2 3
4 4 1 4
4 3 2 2
4 5 3 3
5 3 1 5
5 5 2 5
5 2 3 5
5 4 4 2
15
2 3 1 5
3 2 1 1
3 4 2 1
4 4 1 3
4 6 2 4
4 3 3 6
5 5 1 6
5 1 2 6
5 6 3 1
5 3 4 5
6 6 1 4
6 1 2 5
6 2 3 5
6 3 4 2
6 4 5 4
21
2 2...

result:

ok your solution is correct.

Test #12:

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

input:

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

output:

0
1
2 1 1 2
3
2 3 1 2
3 2 1 3
3 1 2 2
6
2 3 1 3
3 1 1 4
3 2 2 2
4 3 1 2
4 4 2 1
4 1 3 4
10
2 5 1 1
3 5 1 3
3 2 2 3
4 3 1 4
4 2 2 1
4 5 3 3
5 4 1 2
5 1 2 2
5 5 3 1
5 3 4 1
15
2 4 1 4
3 5 1 6
3 6 2 2
4 4 1 3
4 3 2 5
4 2 3 3
5 5 1 1
5 4 2 6
5 6 3 2
5 2 4 6
6 4 1 2
6 1 2 1
6 6 3 4
6 3 4 1
6 5 5 3
21
2 3...

result:

ok your solution is correct.

Test #13:

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

input:

5
156
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 95 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 34 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 14 17 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 130 1 42 1 1 1 1 1 1 1 1 1 1 1 1 90 1 64 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1...

output:

12090
2 144 1 124
3 123 1 109
3 103 2 102
4 54 1 26
4 75 2 3
4 100 3 50
5 146 1 122
5 80 2 125
5 7 3 109
5 156 4 73
6 108 1 85
6 48 2 145
6 26 3 111
6 83 4 62
6 119 5 71
7 156 1 7
7 108 2 6
7 56 3 20
7 152 4 36
7 134 5 3
7 61 6 31
8 142 1 8
8 112 2 91
8 135 3 86
8 47 4 79
8 53 5 9
8 109 6 87
8 132 7...

result:

ok your solution is correct.

Test #14:

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

input:

7
2
1 2
1 2
4
1 4 4 1
2 3 2 4
1 4 3 3
3 1 2 2
39
1 31 38 1 22 35 1 32 36 19 33 1 1 1 4 14 24 35 33 4 1 31 34 1 1 27 1 1 34 8 35 1 1 38 10 1 6 8 10
22 14 2 2 2 20 9 26 2 8 26 23 2 36 36 2 38 2 2 18 27 29 3 28 2 3 31 33 36 2 20 2 11 33 32 2 2 2 32
34 39 11 34 35 3 3 3 16 3 3 3 34 39 3 27 17 30 33 11 3...

output:

1
2 2 1 2
6
2 4 1 4
3 3 1 3
3 2 2 3
4 3 1 2
4 4 2 1
4 2 3 1
741
2 22 1 30
3 38 1 22
3 39 2 2
4 21 1 37
4 18 2 27
4 15 3 4
5 33 1 3
5 5 2 1
5 23 3 37
5 26 4 29
6 39 1 35
6 4 2 7
6 16 3 35
6 26 4 27
6 28 5 28
7 37 1 2
7 14 2 9
7 2 3 5
7 18 4 20
7 38 5 6
7 39 6 7
8 39 1 23
8 1 2 24
8 12 3 19
8 38 4 26
...

result:

ok your solution is correct.

Test #15:

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

input:

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

output:

36
2 8 1 2
3 6 1 1
3 3 2 1
4 2 1 3
4 3 2 9
4 1 3 5
5 8 1 8
5 7 2 5
5 1 3 7
5 3 4 4
6 7 1 6
6 9 2 2
6 2 3 8
6 1 4 8
6 4 5 6
7 5 1 7
7 7 2 4
7 9 3 1
7 3 4 6
7 8 5 5
7 2 6 5
8 9 1 9
8 8 2 6
8 4 3 9
8 6 4 9
8 3 5 9
8 7 6 8
8 2 7 1
9 8 1 5
9 7 2 3
9 2 3 2
9 3 4 7
9 1 5 4
9 4 6 6
9 6 7 6
9 5 8 1
28
2 1 1 ...

result:

ok your solution is correct.

Test #16:

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

input:

9
8
8 7 6 6 2 2 6 2
5 1 6 5 5 4 1 2
5 3 8 1 2 2 4 3
5 4 7 8 7 1 7 1
6 4 8 4 1 6 8 3
3 3 1 8 3 5 4 3
7 6 5 2 7 3 6 8
8 4 7 2 1 7 5 4
6
3 3 6 2 5 2
5 5 4 4 6 1
6 4 1 3 2 4
3 5 3 6 3 1
4 2 2 1 6 5
1 6 5 4 1 2
118
1 18 1 1 1 1 1 1 4 1 115 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 5 1 1 1 1 1 1 18 62 1 1 1 1 1 1 1...

output:

28
2 3 1 1
3 5 1 3
3 7 2 1
4 6 1 5
4 8 2 7
4 2 3 3
5 8 1 4
5 6 2 5
5 5 3 4
5 1 4 5
6 7 1 7
6 6 2 6
6 5 3 2
6 2 4 7
6 1 5 7
7 8 1 6
7 6 2 2
7 5 3 1
7 1 4 4
7 4 5 2
7 3 6 8
8 7 1 8
8 3 2 4
8 1 3 8
8 2 4 3
8 8 5 4
8 4 6 4
8 6 7 2
15
2 5 1 2
3 4 1 1
3 5 2 6
4 6 1 3
4 4 2 1
4 2 3 6
5 1 1 4
5 6 2 2
5 3 3 ...

result:

ok your solution is correct.

Test #17:

score: 0
Accepted
time: 91ms
memory: 4772kb

input:

1
200
10 98 86 3 124 117 19 6 74 143 48 196 32 33 15 5 23 56 138 65 150 46 125 157 43 162 48 141 161 93 179 175 163 1 144 183 105 65 158 195 102 112 69 194 142 177 182 135 60 77 140 117 47 171 5 157 14 115 17 163 130 55 134 74 10 108 117 181 75 154 14 138 106 60 127 25 162 196 172 156 66 41 20 127 1...

output:

19900
2 49 1 192
3 148 1 190
3 98 2 132
4 115 1 53
4 200 2 115
4 88 3 95
5 190 1 80
5 83 2 55
5 184 3 11
5 89 4 123
6 170 1 199
6 179 2 22
6 119 3 117
6 101 4 72
6 145 5 123
7 168 1 14
7 159 2 104
7 91 3 152
7 137 4 197
7 80 5 47
7 187 6 163
8 178 1 3
8 141 2 197
8 151 3 23
8 190 4 81
8 200 5 73
8 1...

result:

ok your solution is correct.

Test #18:

score: 0
Accepted
time: 91ms
memory: 4788kb

input:

1
200
42 73 47 35 98 195 170 82 124 40 112 112 80 136 155 167 74 76 68 175 89 120 162 78 36 65 58 93 75 42 173 84 148 52 29 59 10 32 34 87 101 176 48 36 139 197 170 149 77 157 122 68 96 95 190 130 97 125 36 4 107 61 174 121 48 166 103 182 96 96 128 200 44 188 32 1 196 61 141 123 153 18 181 199 101 5...

output:

19900
2 26 1 71
3 11 1 20
3 96 2 74
4 200 1 132
4 87 2 139
4 39 3 197
5 138 1 187
5 115 2 58
5 151 3 116
5 122 4 167
6 183 1 199
6 153 2 57
6 168 3 90
6 158 4 78
6 4 5 198
7 197 1 195
7 184 2 15
7 43 3 188
7 193 4 190
7 105 5 179
7 84 6 57
8 129 1 89
8 186 2 196
8 168 3 81
8 147 4 103
8 167 5 5
8 19...

result:

ok your solution is correct.

Test #19:

score: 0
Accepted
time: 92ms
memory: 4704kb

input:

1
200
50 94 96 46 14 72 8 114 112 20 65 181 26 198 1 48 129 163 61 44 64 53 39 18 119 183 32 138 194 35 14 24 117 21 136 59 136 63 55 177 106 7 192 127 139 41 171 171 143 62 74 134 110 125 74 197 23 173 159 165 178 70 99 68 42 5 68 172 179 34 38 47 196 194 115 83 20 128 156 79 4 90 151 133 107 164 8...

output:

19900
2 199 1 2
3 200 1 197
3 150 2 70
4 167 1 13
4 130 2 133
4 171 3 192
5 146 1 132
5 131 2 95
5 181 3 143
5 174 4 131
6 198 1 200
6 146 2 108
6 120 3 85
6 192 4 115
6 103 5 158
7 132 1 6
7 170 2 14
7 172 3 196
7 2 4 143
7 151 5 3
7 135 6 2
8 146 1 7
8 162 2 197
8 148 3 184
8 140 4 157
8 183 5 200...

result:

ok your solution is correct.

Test #20:

score: 0
Accepted
time: 11ms
memory: 4416kb

input:

1
200
1 1 1 1 1 1 1 1 169 1 1 1 1 9 1 1 1 1 1 1 1 1 1 1 99 1 196 90 1 1 1 1 1 83 174 1 1 1 83 1 1 73 1 59 1 153 1 1 1 1 1 1 1 1 1 1 28 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 175 1 1 1 1 1 1 1 63 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 102 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 37 1 1...

output:

19900
2 100 1 192
3 142 1 176
3 157 2 120
4 79 1 188
4 151 2 198
4 165 3 57
5 154 1 28
5 188 2 40
5 198 3 200
5 151 4 84
6 196 1 25
6 36 2 54
6 189 3 42
6 155 4 128
6 107 5 79
7 143 1 163
7 174 2 135
7 104 3 128
7 189 4 23
7 133 5 187
7 81 6 176
8 34 1 35
8 190 2 13
8 193 3 45
8 118 4 125
8 186 5 49...

result:

ok your solution is correct.

Extra Test:

score: 0
Extra Test Passed