QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#21145#1824. Special CycleezoilearnerAC ✓120ms4228kbC++144.9kb2022-03-01 21:31:392022-05-08 02:13:50

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-05-08 02:13:50]
  • 评测
  • 测评结果:AC
  • 用时:120ms
  • 内存:4228kb
  • [2022-03-01 21:31:39]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;

#define cout cerr
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,a,b) for(int i=(a);i>=(b);--i)

typedef long long ll;
typedef pair<int,int> pii;
#define FR first
#define SE second

inline void rd(int &x){
	x=0;char ch=getchar();int f=1;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar();
	}
	x*=f;
}

int n,m,K;
#define Maxn 1005
#define E 2000010

void output(vector<int> sol){
	printf("%d\n",sol.size());
	for(int i=0;i<sol.size();++i)printf("%d\n",sol[i]);
	exit(0);
}

vector<int> vec[Maxn];
bool cir[Maxn];
int ALL;
void calc(){
	vector<int> sol;
	rep(u,1,n)
		if(vec[u].size()>0){
			sol.push_back(u);cir[u]=true;
			while(true){
				bool fl=false;
				for(int i=0;i<vec[u].size();++i)
					if(!cir[vec[u][i]]){
						u=vec[u][i];cir[u]=true;sol.push_back(u);
						fl=true;break;
					}
				if(!fl)break;
			}
			output(sol);
		}
}
void addcir(int s,int e){
	//cout<<"s e "<<s<<" "<<e<<endl;
	vec[s].push_back(e);
	vec[e].push_back(s);
	if(vec[s].size()==1)ALL--;else ALL++;
	if(vec[e].size()==1)ALL--;else ALL++;
	if(ALL==n)calc();
}

int rev(int x){
	if(x&1)return x+1;
	return x-1;
}
int p(int x){return (x+1)/2;}
vector<int> e[Maxn];int cnt=0;
namespace P1{
	int del[Maxn],ed[E],delt,edt;
	int head[Maxn],v[E],nxt[E],tot=0;
	pii edge[E];int len=0;
	void ADD(int s,int e){
		cout<<"s e "<<s<<" "<<e<<endl;
		edge[++len]=pii(s,e);
	}
	inline void add_edge(int s,int e){
		tot++;v[tot]=e;nxt[tot]=head[s];head[s]=tot;
		tot++;v[tot]=s;nxt[tot]=head[e];head[e]=tot;
	}
	
	int dfn[Maxn],dfk,low[Maxn];
	int fav[Maxn],d[Maxn];
	void tarjan(int u,int f){
		fav[u]=f;d[u]=0;
		dfn[u]=low[u]=++dfk;
		for(int i=head[u];i;i=nxt[i])
			if(rev(i)!=f&&!del[v[i]]&&!ed[p(i)]){
				if(!dfn[v[i]]){
					tarjan(v[i],i);
					low[u]=min(low[u],low[v[i]]);
				}else{
					low[u]=min(low[u],dfn[v[i]]);
					if(!d[u]||dfn[v[i]]<dfn[v[d[u]]])d[u]=i;
				}
			}
	}
	
	bool Judge(){
		rep(i,1,len)
			if(!del[edge[i].FR]&&!del[edge[i].SE]&&!ed[i])return true;
		return false;
	}
	
	void shrink(){
		while(true){
			dfk=0;
			memset(dfn,0,sizeof(int)*(n+1));
			rep(u,1,n)
				if(!del[u]&&!dfn[u])tarjan(u,0);
			bool fl=true;
			rep(u,1,n)
				if(!del[u]&&low[u]==dfn[u]){
					int t=p(fav[u]);
					if(t){
						if(t>len-cnt){del[edge[t].FR]=delt;del[edge[t].SE]=delt;fl=false;}
						ed[t]=edt;
					}
				}
			if(fl)break;
		}
	}
	void back(){
		rep(u,1,n)
			if(del[u]==delt)del[u]=0;
		rep(i,1,len)
			if(ed[i]==edt)ed[i]=0;
		
	}
	void solve(){
		delt=edt=1;
		rep(i,1,len)add_edge(edge[i].FR,edge[i].SE);
		shrink();
		dfk=0;memset(dfn,0,sizeof(int)*(n+1));
		rep(u,1,n)
			if(!del[u]&&!dfn[u])tarjan(u,0);
		rep(u,1,n)
			if(!del[u])ed[p(d[u])]=ed[p(fav[u])]=2;
		int pre=len;len=0;int zz=cnt;cnt=0;
		rep(i,1,pre)
			if(ed[i]==2){
				if(i>pre-zz){
					cnt++;e[cnt]=e[i-pre+zz];
					edge[++len]=edge[i];
				}else edge[++len]=edge[i];
			}
		rep(i,cnt+1,zz)e[i].clear();
		memset(ed,0,sizeof(int)*(len+1));
		memset(head,0,sizeof(int)*(n+1));tot=0;
		rep(i,1,len)add_edge(edge[i].FR,edge[i].SE);
		if(len==0){
			puts("-1");
			exit(0);
		}
		per(i,len,1)
			if(!del[edge[i].FR]&&!del[edge[i].SE]&&!ed[i]){
				delt++;edt++;
				if(i>len-cnt)del[edge[i].FR]=del[edge[i].SE]=delt;
				ed[i]=edt;
				shrink();
				if(!Judge()){
					back();
					if(i<=len-cnt)addcir(edge[i].FR,edge[i].SE);
					else{
						int z=i-len+cnt;
						for(int j=0;j+1<e[z].size();++j)addcir(e[z][j],e[z][j+1]);
					}
				}
			}
	}
}

namespace P2{
	int head[Maxn],v[E],nxt[E],tot=0;
	int deg[Maxn];
	void add_edge(int s,int e){
		deg[s]++;deg[e]++;
		tot++;v[tot]=e;nxt[tot]=head[s];head[s]=tot;
		tot++;v[tot]=s;nxt[tot]=head[e];head[e]=tot;
	}
	bool vis[Maxn];
	int mx,s;
	vector<int> node;
	void dfs(int u){
		node.push_back(u);
		mx=max(mx,deg[u]);s+=deg[u];vis[u]=true;
		for(int i=head[u];i;i=nxt[i])
			if(!vis[v[i]])
				dfs(v[i]);
	}
	void build(){
		rep(u,1,n)
			if(!vis[u]){
				mx=0;s=0;node.clear();
				dfs(u);s/=2;
				if(mx>2){
					for(int i=0;i<node.size();++i)P1::del[node[i]]=1;
				}else{
					if(s==node.size()-1){
						if(node.size()>1){
							for(int i=0;i<node.size();++i)
								if(deg[node[i]]==1){
									reverse(node.begin(),node.begin()+i+1);
									break;
								}
							cnt++;
							e[cnt]=node;
							for(int i=1;i+1<node.size();++i)P1::del[node[i]]=1;
							P1::ADD(node[0],node[node.size()-1]);
						}
					}else output(node);
				}
			}
	}
}

int main(){
	rd(n);rd(m);rd(K);ALL=n;
	rep(i,1,m){
		int s,e;rd(s);rd(e);
		if(i<=K)P2::add_edge(s,e);
		else P1::ADD(s,e);
	}
	P2::build();
	P1::solve();
	return 0;
}/*
8 10 3
1 2
4 5
7 8
2 3
3 4
1 4
5 6
6 7
5 8
3 8

4 6 3
1 2
1 3
1 4
2 3
3 4
2 4
*/

詳細信息

Test #1:

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

input:

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

output:

6
3
8
7
6
5
4

result:

ok OK

Test #2:

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

input:

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

output:

-1

result:

ok OK: both impossible

Test #3:

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

input:

66 88 22
3 4
6 11
9 10
12 17
15 16
18 23
21 22
24 29
27 28
30 35
33 34
36 41
39 40
42 47
45 46
48 53
51 52
54 59
57 58
60 65
63 64
5 66
1 2
2 3
1 3
4 5
5 6
4 6
7 8
8 9
7 9
10 11
11 12
10 12
13 14
14 15
13 15
16 17
17 18
16 18
19 20
20 21
19 21
22 23
23 24
22 24
25 26
26 27
25 27
28 29
29 30
28 30
31...

output:

22
5
66
65
60
59
54
53
48
47
42
41
36
35
30
29
24
23
18
17
12
11
6

result:

ok OK

Test #4:

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

input:

57 95 32
44 57
2 7
8 48
4 38
17 48
31 49
43 56
38 50
13 15
23 44
8 27
48 54
5 47
25 47
47 51
23 28
1 5
43 46
5 8
25 28
3 10
35 46
10 34
20 23
2 31
26 32
9 37
19 22
16 52
11 26
23 38
16 42
5 28
40 50
30 56
36 39
28 57
42 44
1 45
5 56
12 45
7 9
12 40
3 50
17 27
12 38
40 46
12 25
9 42
20 21
45 49
11 24...

output:

9
11
26
32
40
12
45
42
16
52

result:

ok OK

Test #5:

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

input:

98 93 36
15 81
19 93
57 65
46 80
34 47
9 25
58 78
13 61
8 18
73 90
2 39
5 82
49 64
4 62
40 85
14 79
47 73
10 83
43 65
30 59
80 81
40 41
95 98
3 92
15 55
4 98
31 37
74 86
46 69
24 27
70 79
21 28
12 83
60 84
52 98
17 96
83 93
6 32
53 96
29 66
50 66
27 71
40 53
81 94
14 18
63 98
10 59
10 22
8 25
19 85
...

output:

7
5
82
24
27
42
18
8

result:

ok OK

Test #6:

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

input:

146 277 99
43 110
11 123
76 90
60 88
107 129
38 129
23 49
9 56
125 144
89 138
31 88
74 136
46 126
107 122
31 53
8 18
25 42
12 123
3 128
68 121
28 88
35 65
24 52
24 53
74 108
28 79
85 94
64 113
6 77
128 136
111 146
41 136
14 111
88 125
41 83
48 145
13 29
13 33
69 96
46 130
11 92
31 58
65 112
96 104
1...

output:

13
1
12
123
11
92
102
116
37
101
44
34
54
80

result:

ok OK

Test #7:

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

input:

29 41 10
12 20
10 19
1 5
4 21
13 24
6 9
1 12
11 27
12 22
5 14
5 8
6 27
7 21
20 25
1 8
1 2
8 9
2 26
7 15
18 27
6 19
8 24
7 11
20 26
6 15
2 8
16 19
20 29
14 21
1 7
16 21
10 13
11 29
16 17
8 21
18 20
1 3
2 17
2 9
5 24
22 28

output:

8
2
17
16
19
10
13
24
8

result:

ok OK

Test #8:

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

input:

60 97 23
45 52
18 55
1 53
5 35
37 47
25 43
11 55
5 41
36 59
26 40
38 39
21 51
30 32
27 60
46 51
21 50
19 35
20 26
24 31
4 25
8 37
5 33
33 49
33 46
53 59
18 22
21 37
19 41
11 59
25 52
23 54
22 36
31 55
38 45
28 56
41 45
7 27
24 30
21 57
11 56
15 56
6 22
42 56
15 39
48 53
5 29
31 41
2 31
17 27
5 36
7 ...

output:

5
1
53
59
36
22

result:

ok OK

Test #9:

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

input:

62 41 13
12 48
6 26
37 57
2 23
11 62
42 45
24 59
50 51
16 55
41 60
23 54
12 45
6 51
5 21
20 51
25 42
13 26
37 62
19 61
5 40
7 42
6 37
22 28
46 49
10 23
16 31
44 62
24 57
21 29
15 18
33 61
29 57
21 41
23 27
40 42
5 49
32 55
11 37
44 46
40 59
34 62

output:

10
5
49
46
44
62
11
37
57
29
21

result:

ok OK

Test #10:

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

input:

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

output:

3
3
5
6

result:

ok OK

Test #11:

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

input:

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

output:

-1

result:

ok OK: both impossible

Test #12:

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

input:

30 64 31
13 24
17 29
6 10
1 17
12 18
11 26
29 30
3 19
11 17
4 7
4 29
9 25
15 29
12 27
12 16
10 30
4 21
1 23
1 27
8 30
15 18
20 27
15 17
18 25
19 23
21 27
24 25
26 29
6 8
10 25
11 20
9 16
23 24
8 24
2 22
4 17
5 18
17 20
12 28
23 29
13 18
23 30
4 20
7 28
9 23
5 11
15 19
4 11
2 7
1 22
6 14
11 15
8 20
1...

output:

-1

result:

ok OK: both impossible

Test #13:

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

input:

23 14 3
1 20
5 10
21 22
4 23
8 14
11 23
12 14
17 20
10 14
2 13
1 23
1 15
1 9
5 15

output:

-1

result:

ok OK: both impossible

Test #14:

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

input:

3 2 1
2 3
1 3

output:

-1

result:

ok OK: both impossible

Test #15:

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

input:

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

output:

-1

result:

ok OK: both impossible

Test #16:

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

input:

28 91 42
10 23
4 23
9 22
3 9
14 17
12 13
4 20
14 24
8 28
23 24
4 6
4 19
3 8
3 4
15 25
4 15
7 23
3 24
4 13
4 28
4 16
9 11
10 13
15 27
11 16
23 27
5 24
16 17
19 25
13 19
7 27
1 12
26 27
4 7
16 22
9 15
13 23
4 8
9 13
2 26
21 24
4 26
18 24
10 27
24 26
19 26
8 18
1 6
2 14
5 12
4 5
5 17
19 20
15 17
14 23
...

output:

-1

result:

ok OK: both impossible

Test #17:

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

input:

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

output:

8
1
5
6
7
8
4
3
2

result:

ok OK

Test #18:

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

input:

150 10783 2
22 139
31 85
18 37
10 73
62 129
14 22
33 68
31 140
88 136
39 58
20 40
26 32
64 77
20 79
72 126
53 146
42 68
16 145
6 76
42 66
68 106
64 134
8 123
110 119
89 124
10 26
100 144
60 80
69 74
52 100
93 118
7 73
11 98
44 148
33 129
140 145
53 115
23 52
23 141
6 48
6 150
3 58
43 97
35 132
38 89...

output:

3
1
49
71

result:

ok OK

Test #19:

score: 0
Accepted
time: 25ms
memory: 4048kb

input:

92 4162 52
2 17
55 84
28 64
16 24
32 71
11 18
56 69
78 88
24 30
15 80
12 28
24 26
5 72
61 81
21 52
30 36
35 55
7 72
35 57
65 73
14 21
6 54
6 9
30 90
51 69
29 76
38 63
51 65
20 82
49 79
61 88
79 82
35 66
51 88
21 36
42 51
33 49
1 9
58 67
43 53
22 83
3 9
5 19
23 42
48 74
39 61
16 70
10 33
49 73
57 84
...

output:

5
4
25
41
37
13

result:

ok OK

Test #20:

score: 0
Accepted
time: 57ms
memory: 4172kb

input:

138 8440 10
48 76
49 78
21 97
106 123
55 80
54 127
27 42
50 107
13 27
9 28
61 114
98 131
3 107
57 109
113 135
65 119
13 56
14 32
40 47
75 100
72 123
31 63
46 130
118 119
57 74
52 95
110 132
51 135
43 82
28 48
34 63
11 97
15 47
60 78
25 30
75 111
31 87
61 73
17 51
2 22
25 117
10 95
5 50
66 138
18 100...

output:

4
1
15
31
35

result:

ok OK

Test #21:

score: 0
Accepted
time: 26ms
memory: 3852kb

input:

107 3805 22
87 106
25 94
71 73
20 54
50 85
25 80
7 14
25 37
11 65
50 88
89 98
30 68
39 63
34 100
58 92
1 37
29 103
34 90
3 32
65 80
14 69
17 101
11 13
76 104
16 39
31 41
39 70
71 86
15 25
82 95
19 58
46 55
56 57
54 78
22 50
6 42
2 58
19 78
9 46
38 88
45 93
74 86
19 101
12 74
36 60
60 97
62 82
46 59
...

output:

8
2
78
6
66
82
45
81
59

result:

ok OK

Test #22:

score: 0
Accepted
time: 48ms
memory: 3984kb

input:

98 4558 31
6 89
28 86
29 97
6 30
5 96
8 87
15 51
38 73
31 35
15 50
15 49
39 70
25 40
20 91
20 56
37 42
22 52
5 20
2 59
2 56
13 50
12 61
45 49
1 87
22 65
27 96
7 24
5 48
1 6
16 95
48 73
53 73
20 62
10 82
79 92
49 58
17 24
79 82
60 80
89 95
9 31
34 95
1 5
36 41
2 39
55 74
17 94
18 46
17 27
29 40
67 82...

output:

3
3
72
82

result:

ok OK

Test #23:

score: 0
Accepted
time: 120ms
memory: 4024kb

input:

141 8460 2
35 140
59 115
100 128
22 128
49 120
36 37
60 124
84 102
3 83
26 131
38 129
27 61
1 62
28 73
9 66
8 60
102 106
4 101
44 104
51 77
8 98
23 96
74 92
22 137
113 134
25 138
67 133
35 122
2 121
8 109
36 42
110 118
78 114
88 110
73 76
102 125
26 36
54 141
127 134
50 53
73 77
74 103
66 139
61 89
...

output:

4
1
66
37
83

result:

ok OK

Test #24:

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

input:

149 7462 69
4 38
29 40
112 137
20 115
38 135
65 81
55 137
4 70
29 87
9 16
44 95
25 120
15 34
121 136
69 104
14 35
2 76
51 78
9 145
3 55
106 136
91 115
11 102
9 119
86 126
38 119
7 119
96 110
30 135
113 132
49 65
8 118
2 25
47 83
9 91
93 101
107 139
96 137
62 119
3 44
39 146
104 110
37 89
101 133
68 ...

output:

3
5
72
32

result:

ok OK

Test #25:

score: 0
Accepted
time: 119ms
memory: 4100kb

input:

148 10057 54
17 48
83 85
2 47
139 147
74 77
77 79
35 78
64 77
39 62
23 96
23 40
85 103
18 142
17 63
52 127
7 93
80 101
73 117
30 138
37 122
97 106
43 119
18 48
70 105
34 106
40 57
72 92
48 136
95 100
33 34
37 106
68 80
116 122
21 105
45 69
45 141
43 72
18 47
73 141
44 86
50 65
1 141
31 94
6 8
2 145
...

output:

3
3
54
82

result:

ok OK

Test #26:

score: 0
Accepted
time: 56ms
memory: 4092kb

input:

136 8924 10
40 127
57 132
1 106
81 132
80 107
106 132
35 74
111 122
18 102
88 123
5 10
23 96
65 90
10 112
81 82
32 74
41 89
105 116
4 11
89 127
99 100
35 49
51 79
56 108
51 60
81 134
10 101
103 130
22 105
65 113
4 33
61 69
7 27
21 112
46 74
9 100
110 111
100 120
42 75
33 66
98 104
45 121
2 17
33 82
...

output:

4
2
24
9
72

result:

ok OK

Test #27:

score: 0
Accepted
time: 86ms
memory: 4028kb

input:

134 7947 27
24 32
14 132
3 85
18 76
10 82
3 98
34 125
37 88
8 132
23 118
1 57
7 31
6 32
21 58
65 104
117 131
114 118
52 117
70 83
46 55
47 85
15 24
47 60
28 62
51 88
90 98
1 98
40 68
9 69
37 111
28 132
61 72
54 110
21 22
13 39
6 124
55 105
61 125
14 102
96 127
36 58
73 125
64 110
20 130
70 123
61 62...

output:

3
2
30
124

result:

ok OK

Test #28:

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

input:

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

output:

4
5
6
7
8

result:

ok OK

Test #29:

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

input:

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

output:

6
5
6
7
8
9
10

result:

ok OK

Test #30:

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

input:

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

output:

4
3
4
5
6

result:

ok OK

Test #31:

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

input:

4 4 2
3 4
1 3
2 4
1 4

output:

3
1
3
4

result:

ok OK

Test #32:

score: 0
Accepted
time: 8ms
memory: 3680kb

input:

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

output:

8
1
2
3
4
5
6
7
8

result:

ok OK

Test #33:

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

input:

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

output:

6
1
6
3
5
4
2

result:

ok OK

Test #34:

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

input:

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

output:

4
4
7
9
5

result:

ok OK

Test #35:

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

input:

4 4 2
1 4
3 4
1 3
2 4

output:

3
1
4
3

result:

ok OK

Test #36:

score: 0
Accepted
time: 9ms
memory: 3792kb

input:

101 132 34
28 60
42 56
76 86
67 71
30 41
45 50
35 96
31 48
48 83
62 70
47 82
50 98
5 40
16 54
1 17
31 88
52 80
33 36
75 86
55 83
5 15
21 100
14 31
53 82
93 101
9 71
63 92
82 93
27 39
20 100
46 66
35 82
48 86
14 98
6 85
77 92
8 38
60 84
26 79
55 67
47 55
55 89
86 93
1 64
17 18
33 85
14 46
9 69
5 78
9...

output:

4
9
71
67
97

result:

ok OK

Test #37:

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

input:

18 26 9
1 2
3 4
5 6
7 8
9 10
11 12
13 14
15 16
17 18
1 17
2 16
3 15
4 14
5 13
6 12
7 11
8 10
2 3
4 5
6 7
8 9
10 11
12 13
14 15
16 17
1 18

output:

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

result:

ok OK

Test #38:

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

input:

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

output:

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

result:

ok OK

Test #39:

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

input:

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

output:

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

result:

ok OK

Test #40:

score: 0
Accepted
time: 8ms
memory: 3748kb

input:

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

output:

-1

result:

ok OK: both impossible

Test #41:

score: 0
Accepted
time: 106ms
memory: 4100kb

input:

150 10933 3
94 134
61 132
60 136
5 69
85 132
14 138
8 16
35 113
53 136
75 115
7 63
14 139
39 54
47 92
45 123
74 139
44 140
39 85
44 100
3 148
33 37
35 137
16 68
113 120
18 129
19 145
22 147
72 135
21 98
37 98
87 141
15 43
93 116
39 52
9 104
33 83
58 150
72 83
73 120
10 68
2 117
133 142
107 122
51 97...

output:

3
1
9
74

result:

ok OK