QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#491602#8757. 图FffooooWA 88ms26156kbC++142.9kb2024-07-25 20:26:132024-07-25 20:26:13

Judging History

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

  • [2024-07-25 20:26:13]
  • 评测
  • 测评结果:WA
  • 用时:88ms
  • 内存:26156kb
  • [2024-07-25 20:26:13]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
int mian(); int main() { return mian(); }

const int N = 1e5 + 15, M = 4e5 + 45;
int n, m, k;

int id(const int i, const int j) { return i + (j - 1) * n; }
struct UF {
	int fa[M], siz[M];
	void init_fa() { for(int i = 1; i <= m + m; ++i) fa[i] = i, siz[i] = 1; }
	int get(const int x) { if( x == fa[x] ) return x; return fa[x] = get(fa[x]); }
	void us(int u, int v) {
		u = get(u); v = get(v);
		if( siz[u] < siz[v] ) swap(u, v);
		siz[u] += siz[v]; fa[v] = u;
	}
}uf;

vector<int> eg[M];
void add(const int u, const int v) { eg[u].push_back(v); eg[v].push_back(u); }

int fa[M], dep[M];
void dfs_tree(const int u, const int dad) {
	fa[u] = dad; dep[u] = dep[dad] + 1;
	for(auto v : eg[u]) if( v != dad ) dfs_tree(v, u);
}

int TTT, ST;
void solvp(const int u, const int v) {
	if(ST!= 422)printf("%d %d\n", u, v);
	for(int now = 1; now <= k; ++now) {
		dfs_tree( id(v, now), 0 );
		if(ST!=422)printf("%d ", dep[ id(u, now) ]);
//		if( !dep[id(u, now)] ) while(1);
		int x = id(u, now);
		if(ST!=422)while( x != 0 ) printf("%d ", ( x - 1 ) % n + 1), x = fa[x];
		if(ST!=422)puts("");
	}
}
void solve() {
	scanf("%d%d", &n, &m);
	if(TTT==61 and ST==422) cout<<n<<" "<<m<<endl;
	k = ceil( (double)m / (double)(n - 1) );
	uf.init_fa();
	for(int i = 1; i <= id(n, k); ++i) eg[i].clear(), fa[i] = 0, dep[i] = 0;
	for(int i = 1, u, v; i <= m; ++i) {
		scanf("%d%d", &u, &v);
		if(ST==422)cout<<u<<' '<<v<<endl;
		int l = 1, r = k, now = k + 1;
		while( l <= r ) {
			const int mid = (l + r) >> 1;//只能二分 
			if( uf.get( id(u, mid) ) != uf.get( id(v, mid) ) ) r = mid - 1, now = mid;
			else l = mid + 1;
		}
		if( now <= k ) add( id(u, now), id(v, now) ), uf.us( id(u, now), id(v, now) );
	}
	for(int u = 1; u <= n; ++u) if( uf.get( id(u, k) ) != id(u, k) ) { solvp( u, ( uf.get( id(u, k) ) - 1 ) % n + 1 ); return ; }
	puts("-1");
}
int mian() {
	int T; scanf("%d", &T); ST = T;
//	double st=clock();
	while( T-- ) TTT++, solve();
//	cout<<clock()-st;
	return 0;
} /*
1
2 20
1 2
1 2
2 1
1 2
1 2
2 1
1 2
2 1
1 2
1 2
1 2
1 2
2 1
1 2
1 2
2 1
1 2
1 2
1 2
2 1

给定一张 $n$ 点 $m$ 条边的图,求一个点对 $(u,v)$ 满足他们之间有 $k=\lceil \dfrac{m}{n-1} \rceil$ 条边不相交的路径 
$n\le 10^5, m\le 2\times 10^5$ 
$1s, 512MB$

考虑直接构造出 $k$ 条路经 
那么不妨直接构造出来 $k$ 层图,使得这 $k$ 层图中,任意两个点的路径在 $k$ 张图上互不相交 
也就是每一条边只属于一张图。 
那么对于每一层图,如果要加入的边 $(u,v)$ 已经联通,那么就加入到下一层图中,一直知道第一个不连通的图中 
那么,一层至多有 $n-1$ 条边(一棵树,全联通),于是至少有 $\lceil \dfrac{m}{n-1} \rceil=k$ 层图 
找到第 $k$ 层的任意一队点并在下面的层中找到对应的路径即可 
*/

详细

Test #1:

score: 100
Accepted
time: 47ms
memory: 16160kb

input:

10000
2 20
1 2
1 2
2 1
1 2
1 2
2 1
1 2
2 1
1 2
1 2
1 2
1 2
2 1
1 2
1 2
2 1
1 2
1 2
1 2
2 1
2 20
2 1
2 1
2 1
2 1
2 1
1 2
1 2
1 2
1 2
2 1
1 2
1 2
2 1
1 2
1 2
2 1
1 2
1 2
2 1
1 2
2 20
1 2
2 1
1 2
1 2
2 1
2 1
1 2
1 2
2 1
2 1
1 2
1 2
1 2
1 2
2 1
1 2
1 2
1 2
2 1
2 1
2 20
1 2
2 1
2 1
1 2
1 2
1 2
2 1
1 2
2 ...

output:

1 2
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1 2 
2 1
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
2 2 1 
1 2
2 1 2 
2...

result:

ok Answer correct. (10000 test cases)

Test #2:

score: 0
Accepted
time: 37ms
memory: 18228kb

input:

10000
5 20
2 1
2 5
5 3
3 1
4 5
1 4
4 3
4 5
3 5
5 4
2 3
5 2
3 4
3 5
1 4
4 3
4 2
2 1
1 3
5 1
5 20
4 2
1 3
1 2
4 5
2 4
3 1
5 3
5 1
4 5
4 3
2 4
1 4
4 3
5 2
1 2
3 5
1 5
4 1
3 4
4 3
5 20
1 4
1 3
1 5
5 1
4 5
3 4
4 5
2 3
1 2
2 4
4 5
4 5
2 4
2 5
4 2
4 3
4 2
2 5
2 1
3 1
5 20
2 5
2 3
4 5
4 2
3 4
2 1
5 4
2 5
2 ...

output:

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

result:

ok Answer correct. (10000 test cases)

Test #3:

score: 0
Accepted
time: 30ms
memory: 16244kb

input:

10000
10 20
9 4
8 6
2 10
2 9
7 10
4 6
9 4
2 1
4 7
1 5
7 2
4 1
5 9
7 6
8 2
9 4
5 9
9 8
7 3
2 4
10 20
3 8
8 9
8 7
9 2
3 10
9 3
8 1
9 4
8 9
4 7
7 5
5 10
1 3
3 4
3 7
3 8
3 9
1 4
3 6
2 4
10 20
7 6
8 10
3 8
2 8
4 8
4 8
4 6
4 1
1 7
4 6
5 9
5 2
4 7
10 9
6 7
10 5
2 4
4 1
3 2
4 9
10 20
2 1
9 8
7 6
2 10
9 5
4 ...

output:

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

result:

ok Answer correct. (10000 test cases)

Test #4:

score: 0
Accepted
time: 13ms
memory: 16172kb

input:

2000
50 50
6 10
21 26
12 42
29 2
3 30
3 28
7 44
44 37
11 4
23 12
49 14
34 41
35 48
33 6
27 9
33 1
33 31
43 35
32 31
20 42
27 40
39 29
34 38
21 15
31 17
3 33
17 18
15 44
50 22
20 25
28 44
23 32
3 23
25 30
50 20
17 2
21 41
46 35
26 7
34 45
34 19
21 10
44 4
28 22
36 21
4 49
44 39
4 36
2 15
21 38
50 50
...

output:

7 26
5 7 44 15 21 26 
2 7 26 
10 7
6 10 37 9 24 36 7 
2 10 7 
18 33
2 18 33 
2 18 33 
16 39
2 16 39 
2 16 39 
11 43
6 11 35 19 17 50 43 
4 11 20 50 43 
3 48
10 3 31 12 42 23 10 35 6 16 48 
4 3 23 43 48 
1 6
3 1 2 6 
2 1 6 
17 46
9 17 24 28 20 27 26 36 42 46 
2 17 46 
5 14
9 5 42 22 1 43 23 6 44 14 
...

result:

ok Answer correct. (2000 test cases)

Test #5:

score: 0
Accepted
time: 32ms
memory: 16248kb

input:

200
50 1000
6 33
31 2
17 37
27 22
36 1
35 12
31 3
8 36
22 15
40 45
13 23
23 24
50 46
41 48
49 35
15 30
14 6
7 24
38 27
43 19
30 16
16 31
49 21
47 44
33 9
27 32
48 23
24 33
25 12
23 50
6 27
20 21
48 11
42 23
8 36
3 34
8 14
17 30
27 1
14 40
37 5
23 24
6 24
5 35
38 43
31 48
25 33
4 13
6 37
22 24
31 32
...

output:

2 42
12 2 31 16 30 15 22 27 6 33 24 23 42 
11 2 8 36 47 1 27 6 24 22 43 42 
12 2 44 15 46 49 18 3 5 34 27 40 42 
12 2 37 23 3 36 13 12 8 14 18 16 42 
8 2 37 49 9 29 36 16 42 
3 2 44 42 
7 2 44 41 24 30 45 42 
2 2 42 
3 2 1 42 
9 2 44 5 11 41 22 36 13 42 
10 2 5 20 1 49 26 25 45 39 42 
5 2 16 29 40 4...

result:

ok Answer correct. (200 test cases)

Test #6:

score: 0
Accepted
time: 30ms
memory: 18804kb

input:

20
100 10000
77 84
14 62
84 5
4 67
99 44
54 18
39 53
58 88
32 3
61 19
76 14
28 72
92 34
20 1
14 66
98 25
53 99
55 40
13 70
42 62
32 41
93 14
74 66
92 62
42 12
94 35
26 65
82 85
100 34
79 47
87 59
4 92
46 4
77 63
17 62
32 23
46 76
61 26
89 41
10 18
17 64
55 61
89 42
8 71
75 89
2 81
9 63
42 32
23 34
7...

output:

2 60
10 2 81 99 20 89 41 32 3 28 60 
5 2 53 3 66 60 
6 2 11 13 42 24 60 
13 2 25 66 47 98 72 71 68 39 61 45 15 60 
8 2 69 17 76 20 42 26 60 
13 2 71 62 57 14 100 73 4 40 99 44 67 60 
6 2 100 82 93 55 60 
9 2 69 87 16 88 99 57 37 60 
12 2 31 12 41 74 27 82 53 87 77 9 60 
5 2 71 69 65 60 
8 2 48 76 87...

result:

ok Answer correct. (20 test cases)

Test #7:

score: 0
Accepted
time: 27ms
memory: 16380kb

input:

100
1000 1999
527 98
626 570
505 814
510 660
334 873
893 329
51 818
256 113
165 543
515 780
905 200
560 363
385 813
82 324
661 719
3 624
175 120
22 480
662 730
701 676
124 107
820 707
288 412
596 842
285 574
209 109
897 789
37 371
399 502
715 361
877 504
68 73
919 671
685 732
866 390
975 122
994 263...

output:

6 852
33 6 760 106 795 849 340 169 883 485 495 375 899 172 53 518 786 660 510 629 645 256 303 492 443 231 860 58 701 95 801 877 504 852 
24 6 151 171 955 543 686 57 429 902 26 757 552 614 216 450 724 571 515 910 866 715 466 245 852 
2 6 852 
1 257
31 1 411 850 668 346 821 513 339 196 115 620 996 585...

result:

ok Answer correct. (100 test cases)

Test #8:

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

input:

1000
100 100
8 93
14 86
43 53
73 87
9 5
30 87
23 88
9 18
89 75
49 53
39 91
58 22
86 27
75 1
57 90
20 40
71 55
58 77
63 46
97 95
6 71
19 92
54 24
50 96
30 50
11 79
70 20
79 24
88 33
8 86
18 60
51 58
66 39
93 31
1 47
41 65
45 12
3 93
62 33
38 49
29 91
3 29
15 51
37 56
54 6
85 95
2 81
36 28
10 98
57 26...

output:

56 78
24 56 96 50 30 87 91 29 3 93 8 86 27 76 53 43 40 20 70 9 62 33 88 23 78 
2 56 78 
45 18
11 45 93 13 47 75 23 1 69 59 85 18 
2 45 18 
92 9
9 92 57 85 34 15 30 24 69 9 
2 92 9 
60 7
23 60 87 67 86 88 23 75 21 76 42 15 72 55 98 13 26 78 84 43 63 61 99 7 
2 60 7 
57 13
16 57 88 5 72 3 33 99 46 93 ...

result:

ok Answer correct. (1000 test cases)

Test #9:

score: 0
Accepted
time: 30ms
memory: 16132kb

input:

500
200 399
181 137
41 68
61 54
32 10
41 136
85 112
127 111
51 107
143 189
21 69
149 109
107 120
21 158
175 53
31 48
80 170
46 108
163 85
110 142
2 30
117 128
109 114
142 178
76 43
118 63
36 149
45 74
165 123
43 72
87 185
70 173
132 79
130 163
187 10
189 114
70 22
12 184
200 175
65 169
23 27
1 14
19...

output:

3 179
4 3 105 185 179 
9 3 89 163 26 64 167 164 51 179 
2 3 179 
7 108
17 7 45 69 84 67 107 167 120 4 31 124 57 33 85 195 53 108 
29 7 10 85 98 175 99 158 19 200 163 138 24 27 25 162 83 88 176 50 89 78 161 127 142 5 90 171 86 108 
2 7 108 
7 28
10 7 178 25 170 75 140 17 45 58 28 
12 7 85 156 136 148...

result:

ok Answer correct. (500 test cases)

Test #10:

score: 0
Accepted
time: 34ms
memory: 16256kb

input:

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

output:

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

result:

ok Answer correct. (2197 test cases)

Test #11:

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

input:

1980
5 101
3 5
4 2
5 1
1 4
2 5
1 3
2 5
3 2
4 2
3 1
1 2
5 3
3 4
3 1
1 3
5 3
1 4
2 4
2 3
4 2
4 5
4 5
1 2
3 1
3 4
1 2
3 5
4 1
2 4
3 5
4 3
4 1
2 1
2 1
5 4
5 3
3 5
2 5
4 1
5 3
2 3
3 4
3 4
5 2
3 2
4 3
2 3
4 3
1 5
2 1
1 3
1 4
1 4
2 5
2 1
1 3
3 5
5 3
1 5
3 4
4 2
3 5
4 2
2 4
4 1
3 5
3 5
5 4
1 4
5 3
5 1
5 3
1...

output:

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

result:

ok Answer correct. (1980 test cases)

Test #12:

score: 0
Accepted
time: 53ms
memory: 26156kb

input:

1
100000 200000
34863 14128
21925 31963
32836 60679
64214 73508
66150 45252
9601 33518
33904 58681
94179 37263
91962 58845
44150 57595
75389 55087
95549 80645
35339 82663
93639 89411
91288 79966
6158 91046
34153 16675
38098 20451
49822 20670
34821 40807
67167 98424
75186 55129
47388 80048
47576 3327...

output:

4 48961
101 4 89482 10263 35674 96301 99128 96615 64245 49695 68028 75839 13246 49678 23694 92666 52807 86452 56759 94413 48823 50458 44304 77262 39246 12014 35196 81057 60065 17900 64015 74784 4950 30348 70424 18036 77118 67608 94893 25989 22830 69605 59520 56956 15905 61526 55242 45891 18183 39390...

result:

ok Answer correct. (1 test case)

Test #13:

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

input:

1
100000 100000
83552 10530
25783 47244
84923 13681
21334 91194
91778 58467
19661 74982
25591 89762
59524 51208
87846 82043
11266 66764
81526 43233
68225 71631
59267 57074
14783 69153
4005 38103
10428 8712
16106 97817
65055 2008
87601 98588
44816 64853
13936 1829
49508 54999
20100 23207
3098 59651
5...

output:

40770 6329
345 40770 1337 96616 64771 50434 40948 18518 58116 62606 52464 35487 58673 63072 59131 83880 85446 43126 2799 62096 78123 70922 49405 51628 60575 29704 52822 4293 73984 10921 42047 5513 70609 57221 60219 5417 86487 17774 68054 65568 24840 8768 49563 32076 78497 29916 53142 91247 96576 467...

result:

ok Answer correct. (1 test case)

Test #14:

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

input:

10
10000 10000
3288 319
1296 6368
8450 2814
7356 5128
7375 44
5324 3611
9164 7555
1308 5753
1325 8813
5264 796
602 9263
6701 6141
3612 4277
611 5775
8960 5850
4706 9495
7751 9401
8316 7060
8524 8033
7342 4672
2503 3504
4515 4649
3881 1881
2962 4138
9655 9539
9043 4098
2631 6216
1198 9724
6105 2802
6...

output:

1804 9835
232 1804 4752 9330 1353 6059 6715 5494 8455 8601 4635 4409 5548 5900 2599 1697 1445 7373 9341 311 2510 8006 3021 1625 1773 2760 6285 4906 3942 8082 4398 1801 8195 2225 5012 6728 8789 1076 1762 7547 9651 9505 273 2102 9923 6352 4605 8229 6758 7732 3193 9153 630 9003 3590 7086 3758 993 1083 ...

result:

ok Answer correct. (10 test cases)

Test #15:

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

input:

1000
100 100
8 93
14 86
43 53
73 87
9 5
30 87
23 88
9 18
89 75
49 53
39 91
58 22
86 27
75 1
57 90
20 40
71 55
58 77
63 46
97 95
6 71
19 92
54 24
50 96
30 50
11 79
70 20
79 24
88 33
8 86
18 60
51 58
66 39
93 31
1 47
41 65
45 12
3 93
62 33
38 49
29 91
3 29
15 51
37 56
54 6
85 95
2 81
36 28
10 98
57 26...

output:

56 78
24 56 96 50 30 87 91 29 3 93 8 86 27 76 53 43 40 20 70 9 62 33 88 23 78 
2 56 78 
45 18
11 45 93 13 47 75 23 1 69 59 85 18 
2 45 18 
92 9
9 92 57 85 34 15 30 24 69 9 
2 92 9 
60 7
23 60 87 67 86 88 23 75 21 76 42 15 72 55 98 13 26 78 84 43 63 61 99 7 
2 60 7 
57 13
16 57 88 5 72 3 33 99 46 93 ...

result:

ok Answer correct. (1000 test cases)

Test #16:

score: 0
Accepted
time: 31ms
memory: 18164kb

input:

500
200 399
11 16
126 2
70 102
89 163
54 149
84 74
200 175
126 2
98 56
140 188
5 87
107 120
68 133
19 71
135 116
11 78
105 193
63 44
129 33
182 123
83 161
125 6
86 171
44 2
12 184
130 66
78 175
182 141
188 40
154 42
86 60
106 192
90 189
142 135
12 73
95 146
88 62
161 114
101 42
19 106
154 42
122 137...

output:

126 176
10 126 2 44 182 141 78 125 98 48 176 
2 126 176 
2 126 176 
127 92
47 127 31 111 14 17 114 55 29 200 119 39 195 124 101 105 21 60 51 61 38 129 98 135 97 89 177 159 45 24 106 163 160 142 85 125 145 23 180 81 140 126 169 121 181 194 25 92 
2 127 92 
2 127 92 
190 175
30 190 20 12 127 18 135 14...

result:

ok Answer correct. (500 test cases)

Test #17:

score: 0
Accepted
time: 31ms
memory: 18104kb

input:

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

output:

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

result:

ok Answer correct. (2197 test cases)

Test #18:

score: 0
Accepted
time: 33ms
memory: 16164kb

input:

1980
5 101
4 1
1 2
3 1
1 4
2 1
1 2
3 5
3 1
2 1
3 1
3 1
1 4
2 1
2 1
2 1
1 2
5 3
1 2
2 1
3 1
3 1
4 1
4 1
1 2
3 1
3 1
2 1
3 5
2 1
1 4
2 1
1 3
4 1
1 3
3 5
1 2
3 5
1 4
1 2
1 3
4 1
1 4
3 5
1 4
1 3
4 1
1 2
1 3
5 3
5 3
1 4
1 2
3 1
4 1
4 1
3 5
1 2
4 1
1 2
1 3
1 2
3 5
5 3
1 2
1 3
1 3
4 1
4 1
5 3
3 5
4 1
3 5
5...

output:

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

result:

ok Answer correct. (1980 test cases)

Test #19:

score: 0
Accepted
time: 59ms
memory: 25420kb

input:

1
100000 200000
87045 64020
81145 29667
96830 91785
89750 28062
45195 59300
91075 91364
78904 20649
70802 2933
94952 13184
34881 9027
6909 45228
72094 87157
12710 6185
79492 76809
82773 25162
70583 95131
80195 23414
66965 46121
39034 27901
66559 13084
92952 38920
10715 65225
63505 2126
94217 79830
9...

output:

52352 42784
2 52352 42784 
23 52352 60774 64519 84919 29228 29773 83044 45988 2968 34470 72577 6636 77824 5009 74529 95090 86782 21481 88426 73849 92296 77493 42784 
2 52352 42784 

result:

ok Answer correct. (1 test case)

Test #20:

score: 0
Accepted
time: 30ms
memory: 21824kb

input:

1
100000 100000
83552 10530
25783 47244
84923 13681
21334 91194
91778 58467
19661 74982
25591 89762
59524 51208
87846 82043
11266 66764
81526 43233
68225 71631
59267 57074
14783 69153
4005 38103
10428 8712
16106 97817
65055 2008
87601 98588
44816 64853
13936 1829
49508 54999
20100 23207
3098 59651
5...

output:

40770 6329
345 40770 1337 96616 64771 50434 40948 18518 58116 62606 52464 35487 58673 63072 59131 83880 85446 43126 2799 62096 78123 70922 49405 51628 60575 29704 52822 4293 73984 10921 42047 5513 70609 57221 60219 5417 86487 17774 68054 65568 24840 8768 49563 32076 78497 29916 53142 91247 96576 467...

result:

ok Answer correct. (1 test case)

Test #21:

score: 0
Accepted
time: 20ms
memory: 18676kb

input:

10
10000 10000
3288 319
1296 6368
8450 2814
7356 5128
7375 44
5324 3611
9164 7555
1308 5753
1325 8813
5264 796
602 9263
6701 6141
3612 4277
611 5775
8960 5850
4706 9495
7751 9401
8316 7060
8524 8033
7342 4672
2503 3504
4515 4649
3881 1881
2962 4138
9655 9539
9043 4098
2631 6216
1198 9724
6105 2802
6...

output:

1804 9835
232 1804 4752 9330 1353 6059 6715 5494 8455 8601 4635 4409 5548 5900 2599 1697 1445 7373 9341 311 2510 8006 3021 1625 1773 2760 6285 4906 3942 8082 4398 1801 8195 2225 5012 6728 8789 1076 1762 7547 9651 9505 273 2102 9923 6352 4605 8229 6758 7732 3193 9153 630 9003 3590 7086 3758 993 1083 ...

result:

ok Answer correct. (10 test cases)

Test #22:

score: 0
Accepted
time: 32ms
memory: 16788kb

input:

20
1000 9991
608 923
654 599
933 66
70 763
831 458
568 444
779 393
190 673
732 818
283 551
630 583
95 237
278 681
343 514
190 613
96 150
408 366
995 927
361 632
97 217
460 112
838 136
975 614
897 726
181 42
164 323
243 512
188 849
530 636
822 817
259 623
182 776
442 562
911 462
392 313
143 234
669 1...

output:

62 51
2 62 51 
2 62 51 
2 62 51 
2 62 51 
2 62 51 
2 62 51 
2 62 51 
2 62 51 
37 62 508 384 498 342 953 298 153 548 172 97 760 692 458 371 973 657 565 845 321 65 588 69 156 263 100 828 677 393 390 19 982 730 290 859 511 51 
2 62 51 
2 62 51 
938 708
2 938 708 
2 938 708 
2 938 708 
2 938 708 
53 938...

result:

ok Answer correct. (20 test cases)

Test #23:

score: -100
Wrong Answer
time: 88ms
memory: 16064kb

input:

422
3 733
3 1
2 1
1 2
1 3
3 1
3 1
2 3
2 3
1 3
1 3
2 1
2 3
2 3
3 1
3 1
2 3
3 2
2 1
1 3
2 3
2 1
2 1
3 1
2 3
2 1
2 3
2 3
2 3
2 3
3 1
2 1
2 3
1 2
2 1
2 1
3 2
3 1
3 1
1 2
3 2
2 3
1 3
2 1
2 3
1 3
1 2
3 1
3 1
2 3
1 2
1 3
1 2
2 1
3 1
1 3
3 1
3 1
3 2
1 3
3 1
3 1
3 1
3 1
2 1
2 1
1 2
1 3
3 1
1 3
3 1
1 3
3 2
1 ...

output:

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

result:

FAIL Begin in s. (test case 1)