QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#75242#5446. 琪露诺的符卡交换Famiglistmo100 ✓17ms6076kbC++141.7kb2023-02-04 17:14:302023-02-04 17:14:32

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-02-04 17:14:32]
  • 评测
  • 测评结果:100
  • 用时:17ms
  • 内存:6076kb
  • [2023-02-04 17:14:30]
  • 提交

answer

#include <bits/stdc++.h>
#define pii pair<int, int>
#define fi first
#define se second
using namespace std;
const int N = 205;

char buf[1 << 23], *p1 = buf, *p2 = buf;
#define getchar() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1 ++)
int read() {
	int s = 0, w = 1; char ch = getchar();
	while(!isdigit(ch)) { if(ch == '-') w = -1; ch = getchar(); }
	while(isdigit(ch)) s = s * 10 + (ch ^ 48), ch = getchar();
	return s * w;
}

mt19937 rnd(1145141);
vector<pii> vec[N];
int ans[N][N], matchl[N], matchr[N];
int T, n;

void getmatch(int round) {
	memset(matchr, 0, sizeof(matchr)); 
	for(int i = 1; i <= n; ++ i) {
		static int lst[N];
		vector<int> seq, edge;
		seq.push_back(i);
		
		while(1) {
			int x = seq.back(), t = rnd() % (n - round + 1);
			int r = vec[x][t].se; 
			
			lst[x] = seq.size() - 1;
			edge.push_back(t);
			if(!matchr[r]) break;
			seq.push_back(matchr[r]);
		}
		
		int ptr = 0;
		while(ptr < (int)seq.size()) {
			ptr = lst[seq[ptr]];
			int x = seq[ptr], t = edge[ptr], r = vec[x][t].se;
			matchl[x] = t, matchr[r] = x;
			++ ptr;
		}
	}
	
	for(int i = 1; i <= n; ++ i) 
		ans[i][round] = vec[i][matchl[i]].fi, 
		vec[i].erase(vec[i].begin() + matchl[i]);
}

signed main() {
	T = read();
	while(T --) {
		n = read();
		for(int i = 1; i <= n; ++ i) {
			vec[i].clear();
			for(int j = 1, x; j <= n; ++ j)
				x = read(), vec[i].push_back(pii(j, x)); 
		}
		for(int i = 1; i <= n; ++ i) getmatch(i);
		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, ans[i][j], j, ans[j][i]);
	}
	return 0;
}

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

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 20
Accepted

Test #1:

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

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 109 2 93
1 22 3 132
1 17 4 109
1 79 5 38
1 50 6 68
1 12 7 95
1 14 8 117
1 132 9 45
1 97 10 117
1 71 11 18
1 49 12 72
1 18 13 123
1 2 14 4
1 120 15 44
1 115 16 13
1 101 17 120
1 9 18 97
1 99 19 60
1 118 20 108
1 56 21 72
1 70 22 106
1 8 23 66
1 24 24 12
1 10 25 68
1 66 26 43
1 113 27 87
1 103 ...

result:

ok your solution is correct.

Test #2:

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

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

result:

ok your solution is correct.

Test #3:

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

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 17 2 7
1 47 3 52
1 7 4 77
1 35 5 10
1 33 6 24
1 34 7 23
1 44 8 9
1 38 9 61
1 29 10 3
1 36 11 64
1 40 12 6
1 57 13 3
1 81 14 82
1 4 15 10
1 78 16 33
1 3 17 32
1 31 18 17
1 61 19 80
1 37 20 48
1 32 21 66
1 15 22 10
1 8 23 2
1 54 24 22
1 30 25 22
1 18 26 45
1 12 27 1
1 6 28 47
1 52 29 9
1 5 30 2...

result:

ok your solution is correct.

Test #4:

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

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

result:

ok your solution is correct.

Subtask #2:

score: 20
Accepted

Dependency #1:

100%
Accepted

Test #5:

score: 20
Accepted
time: 9ms
memory: 3976kb

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

result:

ok your solution is correct.

Test #6:

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

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

result:

ok your solution is correct.

Test #7:

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

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

result:

ok your solution is correct.

Test #8:

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

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

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

result:

ok your solution is correct.

Test #10:

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

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

result:

ok your solution is correct.

Test #11:

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

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

result:

ok your solution is correct.

Test #12:

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

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

result:

ok your solution is correct.

Test #13:

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

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 133 2 69
1 149 3 24
1 148 4 13
1 54 5 98
1 100 6 8
1 83 7 11
1 144 8 141
1 136 9 123
1 91 10 69
1 132 11 18
1 47 12 60
1 50 13 75
1 78 14 136
1 134 15 20
1 114 16 109
1 111 17 4
1 69 18 61
1 135 19 84
1 1 20 104
1 15 21 142
1 26 22 90
1 39 23 51
1 30 24 83
1 3 25 43
1 52 26 147
1 62 27 103
1...

result:

ok your solution is correct.

Test #14:

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

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

result:

ok your solution is correct.

Test #15:

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

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

result:

ok your solution is correct.

Test #16:

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

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

result:

ok your solution is correct.

Test #17:

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

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 200 2 110
1 36 3 73
1 78 4 124
1 197 5 158
1 101 6 26
1 95 7 190
1 90 8 120
1 151 9 70
1 68 10 12
1 104 11 51
1 94 12 10
1 53 13 182
1 176 14 132
1 121 15 115
1 152 16 144
1 18 17 67
1 58 18 69
1 195 19 172
1 2 20 131
1 115 21 130
1 46 22 140
1 55 23 150
1 81 24 151
1 91 25 139
1 127 26 190
...

result:

ok your solution is correct.

Test #18:

score: 0
Accepted
time: 12ms
memory: 4400kb

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 23 2 52
1 109 3 121
1 142 4 101
1 119 5 34
1 155 6 187
1 90 7 143
1 25 8 153
1 73 9 144
1 153 10 164
1 89 11 52
1 34 12 166
1 27 13 80
1 152 14 44
1 140 15 35
1 106 16 159
1 124 17 124
1 32 18 173
1 77 19 151
1 92 20 106
1 9 21 96
1 178 22 108
1 22 23 80
1 111 24 105
1 11 25 7
1 58 26 37
1 7...

result:

ok your solution is correct.

Test #19:

score: 0
Accepted
time: 17ms
memory: 4316kb

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 59 2 185
1 119 3 200
1 65 4 115
1 22 5 79
1 175 6 188
1 63 7 61
1 141 8 30
1 177 9 182
1 167 10 120
1 49 11 190
1 29 12 147
1 200 13 198
1 116 14 103
1 187 15 77
1 21 16 69
1 196 17 156
1 173 18 24
1 7 19 98
1 9 20 111
1 96 21 73
1 47 22 52
1 73 23 128
1 12 24 19
1 191 25 90
1 74 26 180
1 48...

result:

ok your solution is correct.

Test #20:

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

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 68 2 111
1 1 3 192
1 78 4 118
1 103 5 34
1 50 6 96
1 6 7 191
1 48 8 105
1 154 9 113
1 109 10 24
1 39 11 141
1 114 12 164
1 183 13 28
1 83 14 131
1 107 15 44
1 23 16 65
1 79 17 132
1 28 18 196
1 43 19 48
1 20 20 20
1 74 21 200
1 59 22 185
1 62 23 12
1 88 24 43
1 51 25 93
1 124 26 119
1 149 27...

result:

ok your solution is correct.

Extra Test:

score: 0
Extra Test Passed