QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#233038#5446. 琪露诺的符卡交换WhangZjian100 ✓380ms18720kbC++142.2kb2023-10-31 11:29:412023-10-31 11:29:42

Judging History

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

  • [2023-10-31 11:29:42]
  • 评测
  • 测评结果:100
  • 用时:380ms
  • 内存:18720kb
  • [2023-10-31 11:29:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1021,inf=1ll<<30;
int head[N],cur[N],cnt;
int st,ed,num,ans;
int d[N];
struct edge{
	int to,nxt,w,i,fl;
	edge(int t,int n,int w1,int inv):to(t),nxt(n),w(w1),i(inv){fl=0;}
	edge(){}
}e[N*N*10];
void add(int x,int y,int w,int inv){
	e[cnt]=edge(y,head[x],w,inv);
	head[x]=cnt;
}
void build(int x,int y,int w){
	cnt++;
	add(x,y,w,cnt+1);
	cnt++;
	add(y,x,0,cnt-1);
}
bool bfs(){
	queue<int> q;
	for(int i=st;i<=ed;i++) d[i]=inf,cur[i]=head[i];
	d[st]=0,q.push(st);
	while(!q.empty()){
		int x=q.front();
		q.pop();
		for(int i=head[x];i>0;i=e[i].nxt){
			int y=e[i].to,w=e[i].w;
			if(w==0||d[y]<inf) continue;
			d[y]=d[x]+1;
			q.push(y);
		} 
	}
	return d[ed]<inf;
}
int dinic(int x,int flow){
	if(x==ed||flow<=0) return flow;
	int res=0;
	for(int &i=cur[x];i>0&&flow>0;i=e[i].nxt){
		int y=e[i].to,w=e[i].w;
		if(d[y]!=d[x]+1||w==0) continue;
		int tmp=dinic(y,min(flow,w));
		if(tmp<=0) d[y]=0;
		flow-=tmp,res+=tmp;
		e[i].w-=tmp,e[e[i].i].w+=tmp;
	}
	return res;
}
int n;
int a[N][N],b[N][N],vis[N][N];
signed main(){
	int T;
	cin>>T;
	while(T--){
		memset(vis,0,sizeof(vis));
		memset(head,-1,sizeof(head));
		cnt=0;
		cin>>n;
		st=0,ed=2*n+1;
		for(int i=1;i<=n;i++)
			for(int j=1;j<=n;j++)
				scanf("%d",&a[i][j]),build(i,a[i][j]+n,1);
		for(int i=1;i<=n;i++) build(st,i,1);
		for(int i=1;i<=n;i++) build(n+i,ed,1);
		for(int orz=1;orz<=n;orz++){
			int test=0;
			while(bfs()){
				test+=dinic(st,inf);
			}	
			for(int x=1;x<=n;x++){
				for(int i=head[x];i>0;i=e[i].nxt){
					if(e[i].to!=st&&e[i].fl==0&&e[i].w==0){
						for(int j=1;j<=n;j++){
							if(a[x][j]==e[i].to-n&&!vis[x][j]){
								b[x][orz]=j;
								vis[x][j]=1;
								break;
							}
						}
						e[i].fl=1,e[e[i].i].w=0;
						break;
					}
				}
			}
			for(int i=head[st];i>0;i=e[i].nxt) e[i].w=1,e[e[i].i].w=0;
			for(int i=head[ed];i>0;i=e[i].nxt) e[i].w=0,e[e[i].i].w=1;
		}
		printf("%d\n",n*(n-1)/2);
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				printf("%d %d %d %d\n",i,b[i][j],j,b[j][i]);
			}
		}	
	}
}
/*
2
3
1 2 2
2 3 3
3 1 1
3
1 2 3
2 3 1
3 2 1
*/

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

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 20
Accepted

Test #1:

score: 20
Accepted
time: 22ms
memory: 13752kb

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
1 2 2 1
1 3 3 1
1 4 4 1
1 5 5 1
1 6 6 1
1 7 7 1
1 8 8 1
1 9 9 1
1 10 10 1
1 11 11 1
1 12 12 1
1 13 13 1
1 14 14 1
1 15 15 1
1 16 16 1
1 17 17 1
1 18 18 1
1 19 19 1
1 20 20 1
1 21 21 1
1 22 22 1
1 23 23 1
1 24 24 1
1 25 25 1
1 26 26 1
1 27 27 1
1 28 28 1
1 29 29 1
1 30 30 1
1 31 31 1
1 32 32 1
1...

result:

ok your solution is correct.

Test #2:

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

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
1 2 2 1
1 3 3 1
1 4 4 1
1 5 5 1
1 6 6 1
1 7 7 1
1 8 8 1
1 9 9 1
1 10 10 1
1 11 11 1
1 12 12 1
1 13 13 1
1 14 14 1
2 3 3 2
2 4 4 2
2 5 5 2
2 6 6 2
2 7 7 2
2 8 8 2
2 9 9 2
2 10 10 2
2 11 11 2
2 12 12 2
2 13 13 2
2 14 14 2
3 4 4 3
3 5 5 3
3 6 6 3
3 7 7 3
3 8 8 3
3 9 9 3
3 10 10 3
3 11 11 3
3 12 12 3...

result:

ok your solution is correct.

Test #3:

score: 0
Accepted
time: 10ms
memory: 12628kb

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
1 2 2 1
1 3 3 1
1 4 4 1
1 5 5 1
1 6 6 1
1 7 7 1
1 8 8 1
1 9 9 1
1 10 10 1
1 11 11 1
1 12 12 1
1 13 13 1
1 14 14 1
1 15 15 1
1 16 16 1
1 17 17 1
1 18 18 1
1 19 19 1
1 20 20 1
1 21 21 1
1 22 22 1
1 23 23 1
1 24 24 1
1 25 25 1
1 26 26 1
1 27 27 1
1 28 28 1
1 29 29 1
1 30 30 1
1 31 31 1
1 32 32 1
1...

result:

ok your solution is correct.

Test #4:

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

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
1 2 2 1
1 3 3 1
2 3 3 2
3
1 2 2 1
1 3 3 1
2 3 3 2
0
55
1 2 2 1
1 3 3 1
1 4 4 1
1 5 5 1
1 6 6 1
1 7 7 1
1 8 8 1
1 9 9 1
1 10 10 1
1 11 11 1
2 3 3 2
2 4 4 2
2 5 5 2
2 6 6 2
2 7 7 2
2 8 8 2
2 9 9 2
2 10 10 2
2 11 11 2
3 4 4 3
3 5 5 3
3 6 6 3
3 7 7 3
3 8 8 3
3 9 9 3
3 10 10 3
3 11 11 3
4 5 5 4
4 6 6 4...

result:

ok your solution is correct.

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #5:

score: 20
Accepted
time: 72ms
memory: 18436kb

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
1 2 2 1
1 3 3 1
1 4 4 1
1 5 5 1
1 6 6 1
1 7 7 1
1 8 8 1
1 9 9 1
1 10 10 1
1 11 11 1
1 12 12 1
1 13 13 1
1 15 14 1
1 14 15 1
1 16 16 1
1 17 17 1
2 3 3 2
2 4 4 2
2 5 5 2
2 6 6 2
2 7 7 2
2 8 8 2
2 9 9 3
2 10 10 2
2 11 11 3
2 12 12 3
2 13 13 2
2 14 14 2
2 17 15 2
2 15 16 2
2 16 17 2
3 4 4 3
3 5 5 3
...

result:

ok your solution is correct.

Test #6:

score: 0
Accepted
time: 70ms
memory: 18268kb

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
1 2 2 1
1 3 3 1
1 4 4 1
1 6 5 2
1 7 6 1
1 8 7 2
1 9 8 1
1 10 9 1
1 11 10 1
1 12 11 2
1 13 12 1
1 14 13 1
1 15 14 1
1 16 15 1
1 17 16 1
1 5 17 1
1 18 18 1
1 19 19 1
1 20 20 1
1 21 21 1
1 22 22 1
1 23 23 1
1 24 24 1
1 25 25 1
1 26 26 1
1 27 27 1
1 28 28 1
2 4 3 2
2 5 4 2
2 6 5 3
2 7 6 2
2 8 7 3
...

result:

ok your solution is correct.

Test #7:

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

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
1 2 2 1
1 3 3 1
1 4 4 1
1 5 5 1
1 6 6 1
1 10 7 1
1 7 8 1
1 8 9 1
1 9 10 1
1 11 11 1
1 12 12 1
1 13 13 1
1 14 14 1
1 15 15 1
1 16 16 1
1 17 17 1
1 18 18 1
1 19 19 1
1 20 20 1
1 21 21 1
1 22 22 1
2 3 3 2
2 4 4 8
2 5 5 2
2 6 6 2
2 22 7 3
2 7 8 21
2 8 9 2
2 9 10 2
2 10 11 2
2 11 12 2
2 12 13 3
2 13 ...

result:

ok your solution is correct.

Test #8:

score: 0
Accepted
time: 15ms
memory: 18260kb

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
1 2 2 1
1 3 3 1
1 4 4 1
1 5 5 1
1 6 6 1
1 7 7 1
1 8 8 1
1 9 9 1
1 10 10 1
1 11 11 1
1 12 12 1
1 13 13 1
1 25 14 1
1 14 15 1
1 15 16 1
1 16 17 1
1 17 18 1
1 18 19 1
1 19 20 1
1 20 21 1
1 21 22 1
1 22 23 1
1 23 24 1
1 24 25 1
1 26 26 1
1 27 27 1
1 28 28 1
1 29 29 1
2 3 3 2
2 4 4 2
2 5 5 2
2 6 6 2
...

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: 5ms
memory: 12192kb

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
1 2 2 2
3
1 2 2 3
1 1 3 3
2 2 3 2
6
1 4 2 4
1 3 3 1
1 1 4 4
2 2 3 3
2 3 4 3
3 4 4 1
10
1 1 2 1
1 3 3 3
1 5 4 2
1 2 5 1
2 3 3 2
2 2 4 4
2 4 5 4
3 4 4 1
3 1 5 5
4 3 5 3
15
1 3 2 4
1 4 3 5
1 1 4 3
1 5 5 4
1 6 6 6
2 5 3 1
2 2 4 1
2 3 5 6
2 1 6 2
3 3 4 5
3 4 5 3
3 6 6 3
4 2 5 2
4 4 6 4
5 5 6 5
21
1 7...

result:

ok your solution is correct.

Test #10:

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

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
1 1 2 2
3
1 2 2 1
1 3 3 1
2 3 3 2
6
1 3 2 2
1 4 3 4
1 2 4 4
2 3 3 3
2 1 4 3
3 2 4 2
10
1 1 2 1
1 4 3 5
1 2 4 5
1 5 5 1
2 3 3 3
2 5 4 3
2 2 5 5
3 1 4 4
3 4 5 4
4 1 5 3
15
1 1 2 4
1 3 3 3
1 4 4 4
1 5 5 6
1 6 6 3
2 1 3 2
2 2 4 5
2 5 5 1
2 6 6 5
3 5 4 1
3 1 5 4
3 4 6 4
4 3 5 5
4 2 6 6
5 2 6 2
21
1 6...

result:

ok your solution is correct.

Test #11:

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

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
1 1 2 2
3
1 1 2 1
1 2 3 3
2 2 3 2
6
1 2 2 3
1 4 3 2
1 3 4 1
2 1 3 4
2 2 4 3
3 3 4 2
10
1 3 2 4
1 4 3 4
1 5 4 4
1 1 5 3
2 3 3 1
2 5 4 5
2 1 5 1
3 5 4 3
3 2 5 2
4 2 5 4
15
1 5 2 3
1 3 3 4
1 1 4 1
1 4 5 1
1 6 6 6
2 4 3 2
2 6 4 6
2 1 5 5
2 2 6 5
3 6 4 2
3 1 5 4
3 3 6 4
4 4 5 2
4 5 6 3
5 6 6 1
21
1 1...

result:

ok your solution is correct.

Test #12:

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

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
1 2 2 1
3
1 1 2 2
1 2 3 1
2 1 3 2
6
1 3 2 3
1 4 3 1
1 2 4 3
2 2 3 2
2 1 4 4
3 4 4 1
10
1 2 2 1
1 3 3 5
1 1 4 3
1 4 5 1
2 5 3 3
2 4 4 1
2 3 5 4
3 2 4 5
3 4 5 3
4 4 5 5
15
1 5 2 3
1 6 3 5
1 1 4 3
1 2 5 4
1 3 6 1
2 5 3 2
2 2 4 4
2 1 5 5
2 6 6 2
3 1 4 5
3 4 5 2
3 3 6 4
4 2 5 6
4 6 6 3
5 1 6 5
21
1 1...

result:

ok your solution is correct.

Test #13:

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

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
1 2 2 1
1 3 3 1
1 109 4 1
1 107 5 156
1 4 6 1
1 5 7 1
1 6 8 1
1 7 9 1
1 8 10 1
1 9 11 2
1 122 12 1
1 10 13 1
1 11 14 17
1 12 15 1
1 13 16 1
1 14 17 1
1 15 18 36
1 16 19 1
1 17 20 124
1 18 21 147
1 84 22 1
1 19 23 1
1 20 24 1
1 21 25 1
1 22 26 1
1 23 27 1
1 24 28 1
1 25 29 94
1 27 30 1
1 28 31 ...

result:

ok your solution is correct.

Test #14:

score: 0
Accepted
time: 54ms
memory: 18720kb

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
1 2 2 2
6
1 2 2 4
1 4 3 3
1 3 4 3
2 2 3 4
2 3 4 2
3 1 4 4
741
1 1 2 35
1 3 3 39
1 34 4 21
1 4 5 7
1 2 6 2
1 38 7 9
1 6 8 38
1 23 9 2
1 18 10 9
1 35 11 39
1 22 12 37
1 26 13 21
1 16 14 35
1 37 15 17
1 29 16 5
1 17 17 8
1 31 18 11
1 11 19 4
1 7 20 38
1 12 21 2
1 13 22 5
1 8 23 13
1 14 24 14
1 21 25 ...

result:

ok your solution is correct.

Test #15:

score: 0
Accepted
time: 105ms
memory: 18596kb

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
1 1 2 6
1 2 3 3
1 9 4 1
1 3 5 8
1 5 6 7
1 4 7 5
1 6 8 9
1 8 9 5
2 7 3 5
2 2 4 8
2 8 5 5
2 9 6 9
2 3 7 4
2 4 8 8
2 5 9 8
3 9 4 5
3 6 5 1
3 2 6 6
3 4 7 7
3 1 8 6
3 8 9 7
4 4 5 6
4 7 6 8
4 3 7 6
4 2 8 2
4 9 9 6
5 4 6 3
5 2 7 9
5 9 8 1
5 7 9 9
6 2 7 8
6 4 8 4
6 1 9 4
7 2 8 3
7 1 9 2
8 5 9 1
28
1 2 2 ...

result:

ok your solution is correct.

Test #16:

score: 0
Accepted
time: 49ms
memory: 18404kb

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
1 1 2 1
1 3 3 5
1 5 4 6
1 4 5 1
1 7 6 1
1 6 7 8
1 8 8 2
2 8 3 6
2 3 4 3
2 6 5 8
2 4 6 7
2 5 7 2
2 7 8 7
3 1 4 8
3 2 5 3
3 8 6 6
3 4 7 6
3 3 8 3
4 5 5 2
4 2 6 2
4 7 7 1
4 1 8 5
5 7 6 4
5 4 7 3
5 6 8 4
6 5 7 4
6 8 8 6
7 5 8 1
15
1 5 2 5
1 4 3 2
1 3 4 6
1 2 5 6
1 6 6 6
2 1 3 5
2 4 4 1
2 6 5 5
2 2 6 ...

result:

ok your solution is correct.

Test #17:

score: 0
Accepted
time: 380ms
memory: 15412kb

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
1 199 2 56
1 13 3 22
1 57 4 50
1 69 5 80
1 98 6 60
1 18 7 23
1 75 8 104
1 139 9 61
1 62 10 153
1 193 11 194
1 88 12 72
1 24 13 180
1 192 14 86
1 170 15 39
1 174 16 98
1 190 17 9
1 91 18 193
1 79 19 134
1 2 20 144
1 181 21 200
1 188 22 13
1 147 23 181
1 187 24 198
1 103 25 18
1 143 26 161
1 179...

result:

ok your solution is correct.

Test #18:

score: 0
Accepted
time: 376ms
memory: 18236kb

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
1 104 2 48
1 72 3 188
1 122 4 37
1 71 5 54
1 132 6 13
1 115 7 195
1 140 8 103
1 18 9 147
1 49 10 58
1 187 11 172
1 20 12 193
1 105 13 34
1 108 14 195
1 81 15 39
1 176 16 62
1 123 17 196
1 107 18 47
1 106 19 197
1 199 20 90
1 197 21 56
1 195 22 35
1 193 23 96
1 28 24 58
1 158 25 108
1 45 26 191...

result:

ok your solution is correct.

Test #19:

score: 0
Accepted
time: 375ms
memory: 13708kb

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
1 200 2 195
1 96 3 58
1 190 4 115
1 81 5 146
1 197 6 27
1 135 7 6
1 140 8 6
1 45 9 20
1 122 10 192
1 33 11 76
1 16 12 199
1 199 13 200
1 164 14 124
1 24 15 45
1 152 16 186
1 89 17 4
1 193 18 89
1 47 19 197
1 107 20 59
1 102 21 200
1 191 22 196
1 34 23 148
1 29 24 70
1 61 25 174
1 11 26 193
1 1...

result:

ok your solution is correct.

Test #20:

score: 0
Accepted
time: 249ms
memory: 18216kb

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
1 109 2 1
1 1 3 1
1 2 4 1
1 35 5 117
1 3 6 1
1 192 7 54
1 4 8 1
1 5 9 1
1 6 10 1
1 7 11 1
1 8 12 142
1 10 13 1
1 11 14 1
1 12 15 1
1 200 16 1
1 13 17 1
1 15 18 191
1 16 19 1
1 188 20 1
1 17 21 1
1 18 22 1
1 19 23 1
1 20 24 1
1 21 25 1
1 22 26 1
1 23 27 1
1 24 28 1
1 26 29 2
1 135 30 1
1 163 31...

result:

ok your solution is correct.

Extra Test:

score: 0
Extra Test Passed