QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#108322#6511. Balancing Sequencesaurelion_solAC ✓240ms3872kbC++141.7kb2023-05-24 15:30:052023-05-24 15:30:07

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-24 15:30:07]
  • 评测
  • 测评结果:AC
  • 用时:240ms
  • 内存:3872kb
  • [2023-05-24 15:30:05]
  • 提交

answer

#include<bits/stdc++.h>
#define rp(i,a,b) for(int i=a;i<=b;++i)
#define pr(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
using namespace std;
const int N=2e3+9;
int T,n,a[2][N],b[2][N],t[2*N],p[2*N];
vector<int> v;
void swp(int i,int j){
	int k=a[0][i]<a[1][i];
	int l=a[0][j]<a[1][j];
	swap(a[k][i],a[l][j]);
	v.pb(k);
	v.pb(i);
	v.pb(l);
	v.pb(j);
	p[min(a[0][i],a[1][i])]=0;
	p[max(a[0][i],a[1][i])]=i;
	p[min(a[0][j],a[1][j])]=0;
	p[max(a[0][j],a[1][j])]=j;
}
bool S(){
	scanf("%d",&n);
	rp(k,0,1)rp(i,1,n){
		scanf("%d",&a[k][i]);
	}
	rp(k,0,1)rp(i,1,n){
		scanf("%d",&b[k][i]);
	}
	memset(t+1,0,n<<3);
	memset(p+1,0,n<<3);
	rp(i,1,n){
		t[min(b[0][i],b[1][i])]=i;
		p[max(a[0][i],a[1][i])]=i;
	}
	rp(i,1,2*n)if(t[i]){
		int j=t[i];
		int x=min(a[0][j],a[1][j]);
		int u=(a[0][j]<a[1][j])^(b[0][j]<b[1][j]);
		if(x<i+u){
			return 0;
		}
		if(x==i){
			continue;
		}
		if(!p[i]){
			return 0;
		} 
		if(u){
			swp(j,p[i]);
		}else{
			bool l=0;
			pr(k,x-1,i+1)if(p[k]){
				swp(j,p[k]);
				l=1;
				break;
			}
			if(!l){
				return 0;
			}
			swp(j,p[i]);
		}
	}
	pr(i,2*n,1)if(t[i]){
		int j=t[i];
		int x=max(a[0][j],a[1][j]);
		int y=max(b[0][j],b[1][j]);
		if(x!=y){
			swp(j,p[y]);
		}
	}
	/*
	rp(k,0,1)rp(i,1,n){
		printf("%d%c",a[k][i]," \n"[i==n]);
	}
	rp(k,0,1)rp(i,1,n){
		printf("%d%c",b[k][i]," \n"[i==n]);
	}
	*/
	return 1;
}
int main(){
	
	//freopen("1.in","r",stdin);
	
	scanf("%d",&T);
	while(T--){
		v.clear();
		if(S()){
			int n=v.size()>>2;
			printf("%d\n",n);
			rp(i,0,n-1){
				printf("%d %d %d %d\n",v[4*i]+1,v[4*i+1],v[4*i+2]+1,v[4*i+3]);
			}
		}else{
			puts("-1");
		}
	}
	return 0;
}

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

详细

Test #1:

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

input:

2
2
1 2
3 4
4 3
2 1
3
1 2 4
3 5 6
1 2 4
5 3 6

output:

-1
1
2 2 2 1

result:

ok correct plan (nYES = 1, nNO = 1) (2 test cases)

Test #2:

score: 0
Accepted
time: 85ms
memory: 3580kb

input:

100000
3
1 6 4
2 3 5
5 6 1
3 4 2
3
3 5 2
6 1 4
4 3 5
6 2 1
3
6 4 3
2 5 1
1 4 5
2 3 6
3
4 2 3
6 1 5
3 1 4
5 2 6
3
4 3 1
5 2 6
4 3 6
5 1 2
3
1 5 6
3 2 4
2 3 5
6 1 4
3
2 5 4
6 1 3
6 3 2
5 4 1
3
3 6 5
2 1 4
3 5 4
2 6 1
3
5 6 3
2 4 1
3 4 6
2 5 1
3
4 5 6
2 3 1
1 2 3
4 6 5
3
3 2 1
6 4 5
3 1 5
2 4 6
3
5 2 3...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
4
1 3 1 1
2 3 1 2
1 3 1 2
1 1 1 2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
2 3 1 1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
1
1 1 2 2
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok correct plan (nYES = 1646, nNO = 98354) (100000 test cases)

Test #3:

score: 0
Accepted
time: 98ms
memory: 3632kb

input:

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

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok correct plan (nYES = 292, nNO = 99708) (100000 test cases)

Test #4:

score: 0
Accepted
time: 113ms
memory: 3576kb

input:

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

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok correct plan (nYES = 51, nNO = 99949) (100000 test cases)

Test #5:

score: 0
Accepted
time: 178ms
memory: 3620kb

input:

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

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok correct plan (nYES = 13, nNO = 99987) (100000 test cases)

Test #6:

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

input:

10000
20
15 26 22 6 17 32 24 29 16 8 9 27 25 28 7 11 2 40 3 14
38 13 20 31 30 33 35 10 39 4 23 1 36 21 18 19 12 34 37 5
22 34 6 30 25 31 20 28 14 37 13 2 32 1 35 27 10 11 38 8
26 39 4 19 33 29 17 40 5 21 15 7 23 16 3 24 18 9 12 36
20
16 21 19 3 36 25 2 22 23 26 12 34 9 33 14 24 40 28 35 1
13 32 4 10...

output:

-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
...

result:

ok correct plan (nYES = 0, nNO = 10000) (10000 test cases)

Test #7:

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

input:

1
2000
3210 3824 856 2261 3740 2833 1675 1387 380 689 1915 1152 1129 1416 145 3845 1211 1450 1328 2069 2649 347 1193 2904 2517 1373 2346 2610 1094 2736 3821 953 3997 3776 1041 539 1516 2739 129 995 1886 2201 1563 1039 173 1566 1286 2336 3283 3473 1550 2664 2854 1778 3419 2394 921 58 1500 1980 1771 5...

output:

-1

result:

ok correct plan (nYES = 0, nNO = 1) (1 test case)

Test #8:

score: 0
Accepted
time: 127ms
memory: 3824kb

input:

100000
3
1 6 4
2 3 5
1 2 4
6 5 3
3
5 3 6
1 4 2
4 3 6
1 5 2
3
3 2 4
1 5 6
3 2 4
1 6 5
3
4 5 6
2 3 1
4 5 6
2 3 1
3
3 5 4
6 2 1
3 6 5
4 2 1
3
4 3 5
2 1 6
3 5 6
2 1 4
3
2 1 3
5 6 4
2 1 3
4 6 5
3
5 4 2
6 1 3
5 4 2
6 1 3
3
1 3 5
2 4 6
1 3 6
4 5 2
3
1 4 5
2 3 6
1 4 5
6 3 2
3
6 2 1
5 4 3
4 2 1
3 5 6
3
1 3 2...

output:

2
1 2 2 1
2 3 2 2
1
2 2 1 1
1
2 3 2 2
0
2
2 1 1 3
1 2 1 3
3
2 3 1 1
1 3 1 1
1 1 1 2
1
2 3 2 1
0
3
2 3 2 1
2 2 1 3
1 3 2 1
1
2 3 2 1
3
1 1 2 2
2 1 2 3
2 2 2 3
1
2 3 2 1
1
1 3 2 1
2
2 3 2 2
2 2 1 1
0
0
1
1 2 2 3
2
2 2 1 1
1 1 2 3
2
1 1 1 3
1 2 1 3
2
2 3 1 2
1 1 1 2
0
1
1 3 1 2
1
1 2 1 3
1
1 3 2 2
2
2 ...

result:

ok correct plan (nYES = 100000, nNO = 0) (100000 test cases)

Test #9:

score: 0
Accepted
time: 154ms
memory: 3580kb

input:

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

output:

3
2 3 1 2
1 1 1 2
2 1 1 2
1
2 4 1 2
2
1 2 2 3
1 4 2 1
2
1 3 2 2
1 4 2 3
2
1 4 2 2
1 3 2 2
0
3
1 2 1 3
2 2 1 3
2 4 1 3
1
2 2 2 1
1
2 1 1 2
1
1 3 2 4
4
1 1 2 4
2 3 2 4
1 3 2 4
2 1 2 4
2
2 2 2 1
2 1 2 4
3
2 3 1 4
1 3 1 2
1 2 1 1
2
2 2 1 1
2 3 1 1
3
2 3 1 4
2 1 2 2
1 4 2 2
4
2 4 2 1
1 4 1 2
2 1 1 2
1 2 ...

result:

ok correct plan (nYES = 100000, nNO = 0) (100000 test cases)

Test #10:

score: 0
Accepted
time: 232ms
memory: 3664kb

input:

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

output:

3
2 1 2 4
2 2 1 1
1 3 2 4
5
1 1 2 5
1 2 2 5
2 4 2 5
2 3 2 5
2 2 2 5
5
1 5 1 3
1 2 1 3
2 1 2 4
2 5 2 4
1 3 2 4
5
1 4 2 1
2 3 1 2
1 3 2 4
1 2 1 5
2 4 2 1
4
2 4 1 1
1 4 2 5
2 4 2 3
2 5 1 2
4
2 5 2 3
2 4 2 3
1 1 1 2
2 3 1 2
3
1 2 2 1
2 2 2 1
2 1 1 3
4
2 1 1 4
2 2 1 4
2 5 1 4
1 5 1 3
4
1 4 2 3
1 5 1 2
2 ...

result:

ok correct plan (nYES = 100000, nNO = 0) (100000 test cases)

Test #11:

score: 0
Accepted
time: 240ms
memory: 3632kb

input:

62500
8
6 11 5 9 4 16 15 12
2 13 1 3 7 8 14 10
16 11 14 13 4 9 12 6
2 5 1 3 7 8 15 10
8
13 16 10 2 4 15 11 6
8 14 7 1 3 9 5 12
4 12 6 10 9 8 14 15
11 13 16 1 3 7 5 2
8
15 11 16 6 14 9 5 2
12 1 4 3 8 10 7 13
10 6 7 12 13 9 5 2
16 1 4 3 8 15 11 14
8
8 2 6 7 3 1 9 4
15 13 5 10 14 16 12 11
8 2 15 7 3 1 ...

output:

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

result:

ok correct plan (nYES = 62500, nNO = 0) (62500 test cases)

Test #12:

score: 0
Accepted
time: 197ms
memory: 3636kb

input:

40000
10
15 9 20 10 7 17 2 19 18 4
16 6 3 14 12 5 11 8 13 1
9 19 14 10 7 18 2 15 4 12
13 6 3 17 16 5 11 8 20 1
10
5 13 17 1 20 14 18 7 12 11
9 19 16 4 15 6 8 10 2 3
5 9 11 1 15 16 4 7 14 18
12 10 13 20 8 6 19 17 2 3
10
4 6 19 8 18 7 17 15 5 2
11 12 16 3 14 9 10 1 13 20
4 6 9 13 17 7 20 16 5 2
19 11 ...

output:

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

result:

ok correct plan (nYES = 40000, nNO = 0) (40000 test cases)

Test #13:

score: 0
Accepted
time: 108ms
memory: 3636kb

input:

10000
20
15 26 22 6 17 32 24 29 16 8 9 27 25 28 7 11 2 40 3 14
38 13 20 31 30 33 35 10 39 4 23 1 36 21 18 19 12 34 37 5
15 12 18 6 17 32 30 13 16 28 40 27 14 20 7 11 2 9 3 33
25 24 37 36 26 21 23 10 31 4 8 1 29 39 19 22 38 35 34 5
20
17 1 39 27 13 25 12 3 35 21 28 33 16 29 22 40 20 19 8 6
32 37 10 9...

output:

24
2 11 1 10
1 18 1 11
1 2 2 17
2 13 1 10
1 13 1 20
1 3 2 15
1 14 2 3
2 6 2 14
2 7 2 13
1 7 2 5
2 14 2 9
2 3 2 19
2 5 2 17
2 9 2 4
2 1 1 20
2 13 1 8
2 2 2 17
2 16 2 15
1 8 2 17
2 18 2 17
2 4 1 10
1 20 1 10
1 10 2 19
2 19 2 17
22
2 13 1 8
1 16 2 19
2 16 1 7
2 17 1 13
2 6 1 18
2 14 1 17
1 14 1 12
2 1 ...

result:

ok correct plan (nYES = 10000, nNO = 0) (10000 test cases)

Test #14:

score: 0
Accepted
time: 58ms
memory: 3620kb

input:

2500
40
20 66 71 79 65 73 42 2 27 63 16 35 45 56 49 52 1 24 78 5 21 15 47 80 68 64 54 11 13 26 39 50 77 29 72 75 62 53 23 30
14 8 51 6 28 67 12 18 70 61 17 34 41 10 59 36 43 9 46 33 74 37 25 40 19 57 31 48 22 55 76 7 4 60 69 58 38 44 32 3
44 53 45 57 17 35 59 2 27 24 16 38 28 69 48 33 1 67 22 5 21 1...

output:

54
1 5 2 11
1 35 1 25
2 35 2 8
1 36 1 1
1 19 2 29
1 10 1 18
1 13 2 5
2 15 1 40
1 37 2 22
2 37 2 39
1 16 2 20
1 6 1 12
1 26 2 16
1 38 2 17
2 38 1 37
1 3 2 5
2 3 1 12
1 24 2 10
2 31 2 30
1 38 2 20
2 26 1 33
2 6 1 12
1 12 2 39
2 16 2 30
1 37 1 23
1 27 2 13
1 15 2 28
2 34 2 9
2 13 1 25
2 9 2 19
2 30 2 2...

result:

ok correct plan (nYES = 2500, nNO = 0) (2500 test cases)

Test #15:

score: 0
Accepted
time: 62ms
memory: 3812kb

input:

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

output:

65
1 50 1 5
2 46 2 49
1 14 2 36
2 28 1 7
2 29 1 5
1 29 2 22
2 44 1 41
2 43 2 18
2 9 2 50
1 48 1 26
1 10 1 43
2 6 2 37
1 45 1 33
2 4 2 18
1 4 1 44
1 21 2 1
2 17 2 29
2 20 2 21
2 32 2 22
2 34 2 39
2 13 2 10
1 13 1 8
1 34 2 12
1 32 2 29
1 8 1 20
1 17 2 39
2 21 2 10
2 4 1 6
2 45 1 31
1 40 1 6
1 31 2 14
...

result:

ok correct plan (nYES = 1600, nNO = 0) (1600 test cases)

Test #16:

score: 0
Accepted
time: 23ms
memory: 3640kb

input:

400
100
180 101 194 36 166 121 61 174 94 153 40 140 102 96 93 68 145 24 16 85 183 55 172 176 181 198 45 81 158 165 99 132 12 29 182 125 190 52 129 141 113 46 189 120 138 199 130 167 106 196 136 78 76 127 13 43 123 144 30 108 82 114 60 35 1 142 8 32 200 86 70 112 155 192 31 119 73 20 90 14 39 168 69 ...

output:

143
1 51 2 84
2 47 1 39
1 47 1 85
1 49 2 81
2 40 1 12
1 40 2 49
2 71 2 42
1 24 2 18
2 66 2 49
1 66 2 4
1 50 2 49
2 50 2 67
1 93 2 7
2 17 1 71
2 28 2 59
1 82 2 75
1 26 1 86
2 26 2 93
1 44 1 53
1 43 2 24
2 43 2 63
1 48 2 51
2 95 2 78
1 95 1 28
2 57 2 80
1 74 1 20
2 14 1 70
2 31 1 14
1 31 2 55
1 10 1 6...

result:

ok correct plan (nYES = 400, nNO = 0) (400 test cases)

Test #17:

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

input:

100
200
276 115 118 75 252 391 300 241 341 172 95 30 134 371 53 261 218 328 70 169 312 189 379 381 107 262 273 398 187 329 123 212 207 364 184 269 229 277 331 347 197 225 320 236 230 351 296 213 182 268 32 186 37 29 369 34 168 202 346 46 198 265 377 10 290 193 148 224 180 393 233 65 114 167 50 397 2...

output:

274
2 172 1 146
1 6 2 143
1 24 2 2
2 24 2 54
1 94 1 172
2 42 2 117
1 63 2 106
2 104 2 120
1 104 2 15
2 137 2 72
2 67 2 6
1 9 2 75
1 165 2 158
2 120 2 4
2 87 1 99
2 130 1 49
1 130 1 73
2 66 1 198
1 18 2 60
1 183 2 31
2 183 2 92
1 101 1 13
2 57 1 188
2 141 2 131
2 68 2 101
2 43 1 183
1 43 2 78
2 7 1 1...

result:

ok correct plan (nYES = 100, nNO = 0) (100 test cases)

Test #18:

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

input:

16
500
937 228 200 167 830 159 627 860 548 749 95 747 312 999 138 101 541 896 699 647 646 279 360 707 890 822 425 441 852 96 526 899 585 701 223 321 264 934 595 267 259 772 81 178 339 557 163 677 359 343 779 738 838 106 516 121 338 191 345 579 295 650 663 470 485 388 293 500 135 364 532 949 496 263 ...

output:

758
1 229 1 80
2 4 1 340
1 131 2 209
2 309 2 236
2 285 1 427
1 486 1 81
1 495 2 470
1 329 1 309
2 203 1 43
1 317 2 413
2 71 1 264
1 92 2 152
2 157 1 285
2 415 1 56
2 345 2 459
2 212 1 69
1 337 1 415
2 64 2 131
1 105 2 317
1 360 2 383
2 360 2 398
2 241 1 341
1 241 1 47
1 116 2 92
1 267 1 4
1 165 2 14...

result:

ok correct plan (nYES = 16, nNO = 0) (16 test cases)

Test #19:

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

input:

4
1000
1506 1787 219 1614 1499 427 1175 1054 871 492 1115 1522 1028 1761 997 177 1086 1942 1821 1351 100 20 1128 1222 1606 1291 952 1495 816 888 841 462 113 1871 652 1519 764 208 1009 849 1061 1660 655 1133 114 1899 838 982 1038 1742 1011 1692 542 636 119 647 530 194 1215 1471 1224 506 1107 1642 171...

output:

1510
2 374 2 980
2 905 2 449
1 669 2 210
2 589 2 221
1 445 1 262
1 144 1 501
2 937 1 809
2 354 2 703
1 354 1 111
1 387 1 212
1 32 2 144
2 949 2 32
1 1000 2 261
1 673 1 38
2 911 2 613
2 101 2 76
2 203 2 321
1 663 1 582
2 663 1 757
1 624 2 630
1 384 2 705
2 855 1 779
2 318 2 445
2 713 1 968
1 713 2 79...

result:

ok correct plan (nYES = 4, nNO = 0) (4 test cases)

Test #20:

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

input:

1
2000
3210 3824 856 2261 3740 2833 1675 1387 380 689 1915 1152 1129 1416 145 3845 1211 1450 1328 2069 2649 347 1193 2904 2517 1373 2346 2610 1094 2736 3821 953 3997 3776 1041 539 1516 2739 129 995 1886 2201 1563 1039 173 1566 1286 2336 3283 3473 1550 2664 2854 1778 3419 2394 921 58 1500 1980 1771 5...

output:

2985
2 622 1 1574
2 1497 1 1307
2 123 2 687
1 141 1 987
1 1009 1 455
2 280 1 1256
2 1813 2 596
2 17 2 1408
1 98 1 1419
1 685 1 954
2 685 1 1720
2 295 1 1633
1 641 1 102
2 1010 2 121
1 398 1 1438
2 319 1 829
1 802 2 1245
2 207 1 280
2 63 1 1644
1 1003 1 614
2 1821 2 1016
2 453 2 633
2 1012 1 1763
1 1...

result:

ok correct plan (nYES = 1, nNO = 0) (1 test case)