QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#582397#9374. EscapeSSAABBEERRAC ✓461ms23456kbC++201.9kb2024-09-22 16:16:372024-09-22 16:16:38

Judging History

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

  • [2024-09-22 16:16:38]
  • 评测
  • 测评结果:AC
  • 用时:461ms
  • 内存:23456kb
  • [2024-09-22 16:16:37]
  • 提交

answer

#include<bits/stdc++.h>
#define lowbit(x) x&(-x)
#define rep(i, a, b) for(int i = a; i <= b; i ++ )
#define pre(i, a, b) for(int i = a; i >= b; i -- )
#define pii pair<int, int>
using namespace std;
const int N = 5e5 + 10;
int n, m, k, d;
vector<int>p[N];
int dis[N][2], st[N][2];
int a[N];
vector<int>path;
void bfs1()
{
	queue<pii>q;
	rep(i, 0, n)
	{
		rep(j, 0, 1)
		{
			dis[i][j] = 0x3f3f3f3f;
		}
	}
	rep(i, 1, k)
	{
		dis[a[i]][0] = 0;
		q.push({a[i], 0});
	}
	while(q.size())
	{
		auto [u, w] = q.front();
		q.pop();
		if(w == d) continue;
		for(auto j : p[u])
		{
			if(dis[j][(w + 1) & 1] < 1e9) continue;
			dis[j][(w + 1) & 1] = w + 1;
			q.push({j, w + 1});
		}
	}
}
void bfs2()
{
	queue<pii>q;
	rep(i, 0, n)
	{
		rep(j, 0, 1)
		{
			st[i][j] = 0x3f3f3f3f;
		}
	}
	st[1][0] = 0;
	q.push({1, 0});
	while(q.size())
	{
		auto [u, w] = q.front();
		q.pop();
		for(auto j : p[u])
		{
			if(st[j][(w + 1) & 1] < 1e9) continue;
			if(dis[j][(w + 1) & 1] < 1e9 && dis[j][(w + 1) & 1] <= w + 1) continue;
			st[j][(w + 1) & 1] = w + 1;
			q.push({j, w + 1});
		}
	}
}
void g(int u, int w)
{
	for(auto j : p[u])
	{
		if(st[j][(w - 1) & 1] == (w - 1))
		{
			path.push_back(j);
			g(j, w - 1);
			break;
		}
	}
}
void solve()
{
	path.clear();
	scanf("%d%d%d", &n, &m, &d);
	rep(i, 1, n) p[i].clear();
	rep(i, 1, m)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		p[u].push_back(v);
		p[v].push_back(u);
	}
	scanf("%d", &k);
	rep(i, 1, k)
	{
		scanf("%d", &a[i]);
	}
	bfs1();
	bfs2();
	if(st[n][0] > 1e9 && st[n][1] > 1e9) printf("-1\n");
	else
	{
		printf("%d\n", min(st[n][0], st[n][1]));
		path.push_back(n);
		g(n, min(st[n][0], st[n][1]));
		reverse(path.begin(), path.end());
		for(auto it : path) printf("%d ", it);
		printf("\n");

	}
}
int main()
{
	int _;
	_ = 1;
	scanf("%d",&_);
	while(_ -- )
	{
		solve();
	}
	return 0;
}

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

详细

Test #1:

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

input:

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

output:

3
1 2 3 7 
-1

result:

ok Accepted! (2 test cases)

Test #2:

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

input:

1
2 1 1
1 2
0

output:

1
1 2 

result:

ok Accepted! (1 test case)

Test #3:

score: 0
Accepted
time: 61ms
memory: 8128kb

input:

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

output:

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

result:

ok Accepted! (100000 test cases)

Test #4:

score: 0
Accepted
time: 75ms
memory: 7880kb

input:

100000
4 4 1
1 3
1 2
1 4
2 4
0
4 3 1
2 4
2 3
1 3
0
4 4 1
1 2
1 4
3 4
2 4
0
4 3 1
1 2
1 3
1 4
0
4 4 1
1 3
1 2
2 4
2 3
0
4 5 1
3 4
1 4
1 2
2 4
2 3
0
4 3 1
1 3
2 3
3 4
0
4 3 1
1 2
1 4
1 3
0
4 4 1
1 3
1 4
1 2
2 3
0
4 3 1
2 3
1 4
3 4
0
4 3 1
3 4
1 4
2 4
0
4 3 1
1 4
3 4
2 3
0
4 4 1
2 3
2 4
1 2
1 3
0
4 3 1...

output:

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

result:

ok Accepted! (100000 test cases)

Test #5:

score: 0
Accepted
time: 104ms
memory: 7876kb

input:

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

result:

ok Accepted! (62500 test cases)

Test #7:

score: 0
Accepted
time: 128ms
memory: 7876kb

input:

50000
10 29 1
5 6
5 10
1 5
4 10
1 9
3 7
8 10
6 10
2 9
1 6
1 2
2 6
5 8
6 7
3 8
5 7
4 9
7 8
2 4
4 6
7 9
3 5
5 9
1 4
1 8
3 10
8 9
2 7
2 10
0
10 34 1
4 9
4 6
7 9
2 5
1 8
6 9
6 7
1 3
3 7
2 6
3 9
1 10
1 6
1 7
9 10
3 8
1 9
8 10
1 5
8 9
3 6
1 2
7 8
3 10
2 3
1 4
2 9
6 10
2 4
5 8
3 4
4 8
5 10
5 6
0
10 22 1
2 ...

output:

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

result:

ok Accepted! (50000 test cases)

Test #8:

score: 0
Accepted
time: 209ms
memory: 16936kb

input:

5
100000 164633 1
26062 33947
13883 65074
4648 69896
22005 63819
58856 62424
73416 88883
19153 64234
28414 74807
38862 78245
12313 70944
11561 25079
84828 90063
24012 36009
29961 85282
17938 77689
44687 94802
47734 62128
9532 51990
20218 79195
10315 94770
55850 88420
15485 45405
57808 77959
82896 85...

output:

11
1 83294 88361 49191 73038 99272 88363 22691 42100 84226 7041 100000 
12
1 11568 17861 89433 2151 48022 97912 8315 14336 19312 39132 82763 100000 
9
1 33568 58411 82376 5848 74277 17580 55852 48497 100000 
12
1 70520 98929 43470 44041 39325 21839 27428 22394 14805 72404 73950 100000 
7
1 91759 876...

result:

ok Accepted! (5 test cases)

Test #9:

score: 0
Accepted
time: 254ms
memory: 22952kb

input:

3
150000 316997 1
23693 114419
2115 110331
82793 90289
51338 82247
38671 42174
98276 144327
76095 134982
47501 147189
43467 115540
54258 130140
26401 39760
6146 50387
61520 99956
53107 89738
81616 86325
38731 97444
19617 103924
57602 96803
59045 128959
49949 90545
85539 99230
44766 111743
32829 8895...

output:

9
1 57240 36206 71174 94237 129686 24200 77869 148289 150000 
8
1 31299 21471 136826 144877 16947 44435 51310 150000 
11
1 11862 127703 105041 36621 18710 59237 41502 134109 59941 48885 150000 

result:

ok Accepted! (3 test cases)

Test #10:

score: 0
Accepted
time: 283ms
memory: 23456kb

input:

2
200000 356769 1
35627 152013
5094 25024
15380 17800
109986 150455
81847 194909
51801 194478
118192 133131
88632 111606
53760 100965
140452 153432
61892 80474
10942 170724
66957 126115
118704 162358
79419 132642
109662 127149
78270 131584
110338 138268
28788 61954
45289 90232
52570 121008
137720 19...

output:

9
1 138286 12257 67280 42113 84268 97304 50482 53366 200000 
6
1 116770 189575 38725 147268 98851 200000 

result:

ok Accepted! (2 test cases)

Test #11:

score: 0
Accepted
time: 461ms
memory: 19512kb

input:

5
100000 348425 1
37319 88906
61712 90432
42100 48458
58598 68622
43762 67591
28358 50298
36807 70603
71371 74932
14733 90875
45373 88396
4047 44917
36325 68710
8572 29109
75124 78440
51357 61117
42238 44061
5 98976
31048 40384
13446 45882
1528 61681
48300 84074
77525 93611
52560 85695
11532 45385
8...

output:

6
1 4505 95652 76320 72587 99741 100000 
15
1 34563 67837 90921 95429 69818 72293 72579 48333 24446 58282 69406 91470 91640 27291 100000 
8
1 84213 75427 87603 85196 12163 89578 90670 100000 
3
1 1736 88576 100000 
87
1 30922 6882 32571 79013 50008 30128 13255 79089 94947 747 94879 63446 30497 57649...

result:

ok Accepted! (5 test cases)

Test #12:

score: 0
Accepted
time: 309ms
memory: 20748kb

input:

3
150000 382060 3
84050 130705
16348 58796
41309 72709
85371 104163
94603 138006
11975 114838
125084 131656
1899 44843
56497 71423
29624 77760
3072 145222
84037 97662
51143 76509
61679 80634
46996 49838
6960 41594
66056 117621
8690 29625
36893 103719
74967 108875
39361 103181
21138 93289
33837 10768...

output:

7
1 107680 42402 54460 13084 72262 138853 150000 
7
1 115499 117660 13591 1974 116049 36613 150000 
10
1 65956 66398 112633 15214 34330 4737 33753 121681 63468 150000 

result:

ok Accepted! (3 test cases)

Test #13:

score: 0
Accepted
time: 63ms
memory: 7904kb

input:

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

output:

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

result:

ok Accepted! (100000 test cases)

Test #14:

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

input:

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

result:

ok Accepted! (100000 test cases)

Test #16:

score: 0
Accepted
time: 121ms
memory: 5856kb

input:

62500
8 7 2
1 2
1 7
1 3
4 7
5 8
4 6
3 5
1 3
8 24 2
2 3
4 6
2 7
1 4
2 8
1 5
4 7
1 6
5 6
2 6
5 8
1 2
1 7
1 3
2 5
7 8
6 8
4 5
5 7
1 8
6 7
3 8
3 6
3 4
2 5 3
8 13 5
2 7
3 8
2 5
2 6
2 4
6 8
1 5
1 8
3 7
2 8
1 6
4 6
4 5
2 3 4
8 20 3
1 6
4 8
5 8
3 4
2 5
1 2
5 6
2 3
7 8
5 7
4 7
2 6
3 8
2 8
4 6
3 7
1 7
1 4
6 7...

output:

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

result:

ok Accepted! (62500 test cases)

Test #17:

score: 0
Accepted
time: 129ms
memory: 7872kb

input:

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

result:

ok Accepted! (100000 test cases)

Test #19:

score: 0
Accepted
time: 89ms
memory: 8156kb

input:

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

output:

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

result:

ok Accepted! (100000 test cases)

Test #20:

score: 0
Accepted
time: 97ms
memory: 7896kb

input:

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

output:

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

result:

ok Accepted! (100000 test cases)

Test #21:

score: 0
Accepted
time: 110ms
memory: 7876kb

input:

50000
10 20 2
2 4
3 10
6 7
4 9
2 10
1 9
3 7
6 8
3 5
2 7
6 10
2 8
4 6
5 6
3 8
1 2
9 10
7 9
8 9
3 4
1 9
10 12 2
1 6
2 4
3 4
1 2
3 5
1 3
6 10
6 7
2 8
8 9
3 10
1 9
1 2
10 24 2
6 10
1 4
3 5
3 8
6 9
1 6
2 9
4 5
6 7
5 6
2 8
1 2
4 8
1 3
3 10
3 7
4 7
4 9
2 10
3 9
2 7
2 5
6 8
4 10
1 3
10 24 1
7 9
4 5
6 8
1 8
...

output:

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

result:

ok Accepted! (50000 test cases)

Test #22:

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

input:

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

output:

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

result:

ok Accepted! (50000 test cases)

Test #23:

score: 0
Accepted
time: 114ms
memory: 5852kb

input:

50000
10 23 1
4 10
2 9
1 3
5 8
4 6
7 8
2 7
3 10
8 9
1 5
5 6
1 4
3 6
6 7
5 10
2 5
6 9
2 3
9 10
3 8
1 7
2 4
7 10
2 7 9
10 22 1
1 5
1 3
5 8
8 10
6 7
2 10
3 8
1 10
6 8
8 9
2 9
4 8
2 6
5 7
4 7
2 4
1 6
3 7
1 9
2 3
7 10
7 9
2 3 9
10 10 1
8 10
4 8
1 4
6 10
5 7
1 10
4 5
7 9
1 3
2 8
2 4 7
10 22 2
3 5
4 8
4 9
...

output:

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

result:

ok Accepted! (50000 test cases)

Test #24:

score: 0
Accepted
time: 110ms
memory: 8188kb

input:

5000
100 357 4
6 15
15 59
7 22
43 54
31 78
26 83
26 37
13 38
90 95
2 95
63 71
29 85
19 25
41 58
4 87
91 98
55 96
37 60
13 88
51 98
40 42
69 71
64 73
11 29
61 78
4 15
30 89
41 74
30 90
15 75
53 81
71 88
24 74
14 49
15 62
38 75
50 58
18 84
40 70
41 52
61 87
48 54
38 46
48 71
20 71
44 95
29 41
63 72
40...

output:

-1
5
1 76 17 7 15 100 
2
1 37 100 
-1
4
1 37 28 70 100 
4
1 50 79 2 100 
-1
5
1 49 25 19 52 100 
5
1 10 50 40 46 100 
4
1 99 62 53 100 
-1
-1
5
1 13 4 11 25 100 
4
1 18 69 89 100 
2
1 53 100 
2
1 89 100 
6
1 21 33 37 24 45 100 
1
1 100 
3
1 66 57 100 
-1
1
1 100 
10
1 51 18 15 4 24 12 88 80 52 100 
...

result:

ok Accepted! (5000 test cases)

Test #25:

score: 0
Accepted
time: 111ms
memory: 7924kb

input:

5000
100 313 3
6 83
37 42
20 64
14 15
26 96
21 71
62 69
75 78
48 62
26 37
13 95
5 51
65 91
16 23
53 66
36 86
39 52
74 89
49 72
31 65
17 51
49 80
91 94
38 60
32 75
17 77
66 73
60 91
5 91
47 72
57 69
34 48
42 44
21 96
36 69
6 17
10 40
55 73
25 72
8 72
33 41
43 93
30 58
7 39
4 83
7 89
35 45
1 48
67 69
...

output:

-1
-1
2
1 72 100 
-1
6
1 87 16 46 5 85 100 
-1
-1
3
1 8 43 100 
3
1 33 97 100 
3
1 4 17 100 
2
1 46 100 
16
1 59 56 22 81 41 63 60 18 51 30 98 75 2 23 55 100 
2
1 62 100 
-1
-1
-1
-1
-1
3
1 33 80 100 
-1
5
1 10 71 65 7 100 
2
1 52 100 
-1
4
1 84 49 8 100 
3
1 3 62 100 
1
1 100 
2
1 14 100 
3
1 27 87...

result:

ok Accepted! (5000 test cases)

Test #26:

score: 0
Accepted
time: 385ms
memory: 18304kb

input:

5
100000 276832 14
24473 54281
45080 87635
17016 79425
81084 82264
37585 38800
38893 99871
51459 92588
56499 83981
33863 43004
9708 56379
83100 98856
7253 52490
78480 82928
6861 58570
27050 66585
34489 39240
21789 61617
30108 30358
58273 98963
54875 59672
39045 66249
4159 85204
58553 97969
47212 540...

output:

6
1 83837 57997 78783 51893 75477 100000 
8
1 89503 24884 5248 65285 11360 47917 97780 100000 
14
1 79367 63998 55577 49599 63010 42249 78764 49127 44205 65365 38244 44961 30732 100000 
6
1 16077 46322 13779 88516 49830 100000 
6
1 6323 1960 81063 45194 83596 100000 

result:

ok Accepted! (5 test cases)

Test #27:

score: 0
Accepted
time: 286ms
memory: 20028kb

input:

5
100000 360073 1
60220 93314
71460 71858
8920 75977
16641 93471
9049 39831
82959 97635
39989 51225
19144 82137
45837 83200
72120 90057
21622 36662
17859 18350
29745 84418
31918 81289
16276 57337
42878 91147
14850 60586
60339 79370
39349 80217
40075 45493
424 53509
13396 70120
65754 70241
1459 96612...

output:

7
1 73741 40901 59233 21398 19334 42036 100000 
10
1 47965 74339 20687 65096 74904 35821 68017 54658 4092 100000 
9
1 5550 45707 78518 57441 44246 49833 30254 27977 100000 
7
1 84202 4861 88983 68594 48835 22069 100000 
7
1 1476 44306 21231 84703 67152 65696 100000 

result:

ok Accepted! (5 test cases)

Test #28:

score: 0
Accepted
time: 257ms
memory: 19248kb

input:

5
100000 186539 12
16669 91928
46021 93209
30533 65353
46882 64671
23670 75527
13367 80086
80482 99650
44250 58607
6042 17051
26700 37302
72624 93703
7951 39285
2403 12819
26149 66545
12531 86407
36390 38166
49144 95618
91253 97708
28479 52746
45141 87610
44422 57660
26780 57220
18873 79619
83712 90...

output:

-1
-1
-1
-1
18
1 10529 64174 81455 13674 13472 6420 63956 9899 63296 51331 30406 80001 76037 33870 37150 71908 34219 100000 

result:

ok Accepted! (5 test cases)

Test #29:

score: 0
Accepted
time: 245ms
memory: 17904kb

input:

5
100000 330963 5
4290 57418
30487 63923
17703 81407
2001 32018
48817 88606
11993 55694
64101 69599
13583 63462
74766 88069
16577 87238
25801 46439
70067 95365
4689 91791
6477 90155
30557 76998
67478 81452
40530 83204
6476 84481
10483 70029
33015 43798
31151 72887
34977 63695
54641 67293
17454 99328...

output:

6
1 54209 65777 99502 65464 48614 100000 
6
1 46254 26013 58339 53854 8456 100000 
-1
42
1 83668 63764 58203 36172 30266 88176 92457 82829 10640 97165 42406 41247 75876 68474 84135 70009 1108 93293 2515 47807 55126 40779 99275 92579 83511 66735 40799 20131 58717 23098 25973 64708 32791 4489 26646 34...

result:

ok Accepted! (5 test cases)

Test #30:

score: 0
Accepted
time: 179ms
memory: 10292kb

input:

25
20000 21599 20
5691 15335
7350 16365
14821 14910
2798 7054
341 16409
3805 7702
2730 13329
11410 19411
540 16963
6696 16434
5724 13721
11636 13618
8646 14378
5271 17484
3231 12164
2068 17322
2557 9139
9124 14839
3805 14244
9745 19151
2758 7298
1983 10988
2617 12823
8309 17149
2705 10164
3812 6544
...

output:

-1
23
1 12513 16776 921 1988 301 1703 15198 12424 16384 16268 711 15104 2827 17016 19989 14612 11060 13091 17165 2096 2999 19808 20000 
-1
-1
6
1 11540 13638 14014 6860 18794 20000 
-1
6
1 18056 6541 13230 5601 516 20000 
10
1 12435 16407 8217 1370 17636 12827 14999 10327 16158 20000 
-1
-1
-1
-1
-1...

result:

ok Accepted! (25 test cases)

Test #31:

score: 0
Accepted
time: 130ms
memory: 13784kb

input:

5
100000 99999 25000
71849 78687
2449 99240
70877 86288
77064 87772
75321 82268
20787 52974
61561 77388
59667 64595
66129 71359
51789 77986
61501 86723
36216 99627
38138 72389
10695 64830
28445 92693
1263 59607
67906 98540
48348 64080
16623 38796
19557 41954
12314 36537
48632 81858
27489 99870
41251...

output:

50000
1 24237 86256 37085 39791 65595 83066 12762 27999 60151 43128 31946 59748 53919 69169 47729 11065 70312 91725 84317 48863 30479 53746 84711 70856 28664 37322 93314 61532 39402 10911 70610 79431 36850 49649 72188 92836 32228 56155 45031 26590 49940 47362 6773 14876 22400 98909 53545 68819 57822...

result:

ok Accepted! (5 test cases)

Test #32:

score: 0
Accepted
time: 134ms
memory: 13644kb

input:

5
100000 99999 10000
26931 42406
43956 57285
23539 77566
788 64322
73627 89080
233 31873
68135 83999
64408 73859
75995 97039
44952 98763
8125 99248
14494 84406
35975 68679
18546 97702
4755 56332
8403 72142
69539 98206
19287 20080
40864 92803
10539 87170
65483 74527
34181 60584
52307 73943
5616 34412...

output:

89999
1 56879 65206 65803 2801 36923 86779 30292 51564 53344 47579 54819 81019 34495 27027 30544 81091 87127 92930 36081 44497 56227 37569 85004 72314 61289 55957 56512 58480 72821 12080 18132 77348 19084 51737 62201 98174 11380 25112 83589 75132 54271 21696 15307 79763 38749 5358 28460 75170 35326 ...

result:

ok Accepted! (5 test cases)

Test #33:

score: 0
Accepted
time: 133ms
memory: 13556kb

input:

5
100000 100004 10000
9613 86923
27292 64512
20315 73322
16720 48054
65246 88171
22528 63958
15800 40083
2313 71423
40875 76959
4107 82763
6925 95761
20268 82307
52643 69122
73845 95186
48767 62158
15829 20601
13089 54485
6994 63114
46512 86408
66885 73873
23534 96978
61228 68025
53935 83532
33739 4...

output:

49994
1 87718 67031 65114 30515 29511 16837 14731 6248 73483 49989 54604 82038 19348 12035 33716 9275 88977 26621 94230 30930 4863 8443 40231 61952 4896 5324 65054 91443 95486 36196 70700 43876 62359 85 77047 63122 64653 78453 62393 88571 36078 1713 66237 36657 24173 23197 6232 39811 89175 51242 689...

result:

ok Accepted! (5 test cases)

Test #34:

score: 0
Accepted
time: 167ms
memory: 13476kb

input:

5
100000 100004 10000
5773 87232
73719 74076
53954 65067
2944 87701
5183 99203
32617 75493
73069 79638
61694 69604
3865 44130
5136 36027
60032 94674
10895 19968
42770 80522
91882 98227
365 78567
39966 50329
16467 40624
52895 64350
14032 95135
54129 99004
22436 70168
47873 89492
33730 50116
12602 566...

output:

49992
1 16837 14731 6248 73483 49989 54604 82038 19348 12035 33716 9275 88977 26621 94230 30930 4863 8443 40231 61952 4896 5324 65054 91443 95486 36196 70700 43876 62359 85 77047 63122 64653 78453 62393 88571 36078 1713 66237 36657 24173 23197 6232 39811 89175 51242 68921 3574 46189 95821 64887 4784...

result:

ok Accepted! (5 test cases)

Test #35:

score: 0
Accepted
time: 139ms
memory: 17856kb

input:

5
100000 100009 5000
72885 76077
57393 90495
14229 89882
9551 98839
14916 59763
7398 19396
5902 51479
61200 67392
11564 68588
4611 88122
24544 78967
7934 13032
53008 90323
23238 52561
39132 78035
86418 93704
79002 88806
16911 76687
55199 98474
21367 38911
10027 27287
6570 80404
26058 28838
71356 843...

output:

49994
1 30219 22502 22186 60890 14231 67054 16812 11344 12011 32976 70971 58826 52468 8878 43179 67718 56283 4681 18624 80304 72203 23978 75934 22026 18720 217 80225 69964 48262 90133 54878 86788 76301 85145 13347 26508 9219 7031 23316 79069 58731 18430 16820 85900 52084 29466 31432 86512 84576 1360...

result:

ok Accepted! (5 test cases)

Test #36:

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

input:

5
100000 100029 10000
47722 66319
17930 64968
17162 68535
36886 76993
46769 61273
36672 82849
25559 31060
36078 65425
73984 85349
74601 87121
29561 47073
33924 45047
2090 15721
51181 52843
9089 14725
71760 73372
10425 27863
38004 67151
26038 82207
50819 71491
70674 98116
44790 58077
66673 92559
4749...

output:

49971
1 11366 41421 63688 25391 63493 10454 38025 10033 58123 11217 34752 24406 95760 41027 80344 79898 68860 32818 17082 52878 40830 15127 43196 33231 34323 8131 62661 52229 39281 14034 66289 72563 69016 97003 76316 14569 97800 75645 13681 75030 9557 53030 60755 74879 2327 51532 52351 4457 36101 62...

result:

ok Accepted! (5 test cases)

Test #37:

score: 0
Accepted
time: 128ms
memory: 13384kb

input:

5
100000 100059 5000
33414 44188
14928 59481
3577 24921
47644 72415
16076 35242
13427 55703
38819 80351
44667 92161
49213 88392
45351 83646
1621 98505
4506 69335
47156 65219
15446 75756
24559 50524
43369 55142
31985 58276
17006 98374
50863 93966
12276 24387
33049 95734
45786 83352
8091 17893
47490 6...

output:

1259
1 86426 59689 25556 41 38521 20684 89548 28280 64548 86153 85395 38178 60157 82709 86502 76569 16102 62939 43507 57487 65637 38616 90715 10861 38261 84669 89056 13083 71834 31506 37288 89374 11409 78766 85381 53303 81794 88390 57718 91139 54144 75849 61697 93319 81450 11877 54469 58595 59965 51...

result:

ok Accepted! (5 test cases)

Extra Test:

score: 0
Extra Test Passed