QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#108273#6511. Balancing Sequencesvme50AC ✓188ms3920kbC++171021b2023-05-24 10:12:072023-05-24 10:12:09

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 10:12:09]
  • 评测
  • 测评结果:AC
  • 用时:188ms
  • 内存:3920kb
  • [2023-05-24 10:12:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define LIM 10000005
#define pb push_back
int T,n,tp,a[N],b[N],psA[N],psB[N];struct Node {int x,y;}ans[N];
void f(int x,int y)
{
	swap(a[x],a[y]);swap(psA[a[x]],psA[a[y]]);
	ans[++tp]=(Node) {x,y};
}
int f1(int x) {return x<=n?x+n:x-n;}
void wr(int x) {if(x<=n) printf("1 %d",x);else printf("2 %d",x-n);}
void slv()
{
	scanf("%d",&n);tp=0;
	for(int i=1;i<=n*2;++i) scanf("%d",&a[i]),psA[a[i]]=i;
	for(int i=1;i<=n*2;++i) scanf("%d",&b[i]),psB[b[i]]=i;
	for(int i=1;i<=n*2;++i) if(psA[i]!=psB[i])
	{
		if(a[f1(psA[i])]>i) {printf("-1\n");return;}
		if(a[psB[i]]>a[f1(psB[i])]) f(psA[i],psB[i]);
		else
		{
			bool fl=0;
			for(int j=i+1;j<a[psB[i]];++j) if(j>a[f1(psA[j])])
			{f(psA[j],f1(psB[i]));f(psA[i],psB[i]);fl=1;break;}
			if(!fl) {printf("-1\n");return;}
		}
	}printf("%d\n",tp);
	for(int i=1;i<=tp;++i)
		wr(ans[i].x),putchar(' '),wr(ans[i].y),putchar('\n');
}
int main() {scanf("%d",&T);while(T--) slv();return 0;}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 3876kb

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 1 2 2

result:

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

Test #2:

score: 0
Accepted
time: 77ms
memory: 3844kb

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 1 1 3
1 2 2 3
1 3 1 1
1 2 1 3
-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
2 2 1 1
-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: 105ms
memory: 3840kb

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: 126ms
memory: 3728kb

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: 148ms
memory: 3708kb

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: 45ms
memory: 3528kb

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: 3580kb

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: 108ms
memory: 3660kb

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
2 1 1 2
2 2 2 3
1
2 2 1 1
1
2 2 2 3
0
2
1 3 2 1
1 2 1 3
3
1 2 1 1
1 2 2 3
1 3 1 2
1
2 3 2 1
0
3
2 1 2 3
2 2 2 1
1 3 2 2
1
2 1 2 3
3
2 2 1 1
2 3 2 1
2 3 2 2
1
2 1 2 3
1
1 3 2 1
2
2 3 1 1
2 2 2 3
0
0
1
2 3 1 2
2
1 1 2 2
1 1 2 3
2
1 2 1 3
1 2 1 1
2
1 1 1 2
1 1 2 3
0
1
1 2 1 3
1
1 2 1 3
1
1 3 2 2
2
1 ...

result:

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

Test #9:

score: 0
Accepted
time: 135ms
memory: 3648kb

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
1 2 2 3
1 2 1 1
2 1 1 2
1
1 2 2 4
2
2 1 1 4
2 3 1 2
2
2 2 1 3
2 3 1 4
2
1 3 2 2
1 3 1 4
0
3
1 3 1 2
2 4 1 3
2 2 2 4
1
2 2 2 1
1
1 2 2 1
1
1 3 2 4
4
2 4 1 1
2 1 2 4
2 1 2 3
1 3 2 1
2
2 1 2 2
2 4 2 1
3
1 4 2 3
1 2 1 3
1 1 1 2
2
2 3 1 1
2 3 2 2
3
2 1 1 4
2 2 2 1
2 2 2 3
4
2 1 2 4
1 4 2 1
2 3 1 2
1 4 ...

result:

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

Test #10:

score: 0
Accepted
time: 183ms
memory: 3588kb

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

result:

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

Test #11:

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

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

result:

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

Test #12:

score: 0
Accepted
time: 185ms
memory: 3660kb

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:

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

result:

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

Test #13:

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

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

result:

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

Test #14:

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

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
2 11 1 5
1 1 1 35
2 8 2 35
1 35 1 36
2 29 1 19
1 18 1 10
2 5 1 13
1 40 2 15
2 20 1 37
2 39 2 37
1 37 1 16
1 12 1 6
2 16 1 26
2 39 1 38
2 22 2 38
1 38 1 12
2 13 1 27
1 7 1 35
2 17 1 23
2 22 1 1
2 5 1 3
2 19 2 9
2 17 1 37
2 28 1 15
2 28 2 30
1 32 2 29
2 3 2 6
2 17 1 38
2 39 1 2
2 13 1 33
2 28 2 31
...

result:

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

Test #15:

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

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:

63
1 5 1 50
2 49 2 46
2 36 1 14
1 7 2 28
1 41 2 29
2 22 1 29
2 29 2 44
2 18 2 43
2 50 2 9
1 26 1 48
1 43 1 10
2 37 2 6
1 33 1 45
2 1 2 4
1 44 1 4
2 4 1 21
1 5 2 17
2 21 2 20
1 17 2 38
2 45 2 37
2 22 2 32
2 39 2 34
2 10 2 13
1 20 1 8
1 6 2 4
2 19 1 42
1 20 1 13
1 5 1 32
1 28 1 3
2 48 1 30
2 18 1 40
2...

result:

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

Test #16:

score: 0
Accepted
time: 21ms
memory: 3704kb

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:

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

result:

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

Test #17:

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

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

result:

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

Test #18:

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

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 80 1 229
1 340 2 4
2 209 1 131
2 236 2 309
1 427 2 285
1 81 1 486
2 470 1 495
1 309 1 329
1 43 2 203
2 413 1 317
1 264 2 71
2 152 1 92
1 285 2 157
1 56 2 415
2 459 2 345
1 69 2 212
1 415 1 337
2 131 2 64
2 317 1 105
1 47 1 360
2 398 2 360
2 92 2 241
1 360 1 241
2 241 1 116
1 4 1 267
2 141 1 16...

result:

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

Test #19:

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

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:

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

result:

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

Test #20:

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

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:

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

result:

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