QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#648155#9189. Make them Meetxyz12334 8ms16368kbC++234.1kb2024-10-17 17:20:172024-10-17 17:20:20

Judging History

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

  • [2024-10-17 17:20:20]
  • 评测
  • 测评结果:34
  • 用时:8ms
  • 内存:16368kb
  • [2024-10-17 17:20:17]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
long long T,a,b,c,d[1000001],v[1000001],o,h[1000001],fa[1000001],q,w,e,an,cn,st[1000001],u[1000001],de[1000001],rt,vi[1000001],si[1000001],cnn;
struct p{long long q,w;}l[1000001];
vector<int> qu[1000001],qu1[1000001],qu2[1000001],qu3[1000001];
void dfs(int qq,int ww)
{
	v[qq]=1;
	for(int i=0;i<qu[qq].size();i++)
	{
		if(qu[qq][i]!=ww)
		{
			if(!v[qu[qq][i]])
			{
				qu2[qq].push_back(qu[qq][i]);
				qu2[qu[qq][i]].push_back(qq);
				qu1[qq].push_back(qu[qq][i]);
				de[qu[qq][i]]=de[qq]+1;
				dfs(qu[qq][i],qq);
			}
		}
	}
}
void dfs2(int qq,int ww)
{
	vi[qq]=1;
	for(int i=0;i<qu1[qq].size();i++) dfs2(qu1[qq][i],qq);
}
void dfs1(int qq,int ww)
{
	v[qq]=1;
	if(!ww)
	{
		for(int i=0;i<qu2[qq].size();i++)
		{
			if(!v[qu2[qq][i]]) qu3[qq].push_back(qu2[qq][i]),dfs1(qu2[qq][i],qq);
		}
	}
	else
	{
		if(vi[qq])
		{
			for(int i=0;i<qu2[qq].size();i++)
			{
				if(!v[qu2[qq][i]]) qu3[qq].push_back(qu2[qq][i]),dfs1(qu2[qq][i],qq); 
			}
			for(int i=0;i<qu[qq].size();i++)
			{
				if(!v[qu[qq][i]]&&!vi[qu[qq][i]]) qu3[qq].push_back(qu[qq][i]),dfs1(qu[qq][i],qq);
			}
		}
		else
		{
			for(int i=0;i<qu[qq].size();i++)
			{
				if(!v[qu[qq][i]]&&!vi[qu[qq][i]]) qu3[qq].push_back(qu[qq][i]),dfs1(qu[qq][i],qq);
			}
		}
	}
}
void dfs3(int qq)
{
	si[qq]=1;
	for(int i=0;i<qu3[qq].size();i++) dfs3(qu[qq][i]),si[qq]+=si[qu[qq][i]];
}
vector<int> tmp,ans[1000001];
void dfs4(int qq)
{
	for(int i=0;i<qu3[qq].size();i++)
	{
		tmp.clear();
		for(int j=0;j<a;j++)
		{
			if(j+1==qq||j+1==qu3[qq][i]) tmp.push_back(qq);
			else tmp.push_back(j+1);
		}
		ans[++cnn]=tmp;
		dfs4(qu3[qq][i]);
		tmp.clear();
		for(int j=0;j<a;j++)
		{
			if(j+1==qq||j+1==qu3[qq][i]) tmp.push_back(qq);
			else tmp.push_back(j+1);
		}
		ans[++cnn]=tmp;
	}
}
void work(int qq)
{
	tmp.clear();
	for(int i=0;i<a;i++) tmp.push_back(i+1);
	for(int i=0;i<qu3[qq].size();i++) tmp[qu3[qq][i]-1]=qq;
	ans[++cnn]=tmp;
}
int vv[1000001];
vector<p> tp;
void dfs5(int qq)
{
	for(int i=0;i<qu3[qq].size();i++)
	{
		if(d[qq]==0&&d[qu3[qq][i]]>0)
		{
			tp.push_back(p{qq,qu3[qq][i]});
		}
		dfs5(qu3[qq][i]);
	}
}
int get(int qq)
{
	while(d[qq]==0)
	{
		tmp.clear();
		for(int i=0;i<=a;i++) vv[i]=0;
		for(int i=1;i<=a;i++) tmp.push_back(i);
		tp.clear();
		dfs5(qq);
		for(int i=0;i<tp.size();i++)
		{
			if(!vv[tp[i].q]&&!vv[tp[i].w])
			{
				swap(d[tp[i].q],d[tp[i].w]);
				tmp[tp[i].w-1]=tp[i].q;
				vv[tp[i].q]=vv[tp[i].w]=1;
			}
		}
		ans[++cnn]=tmp;
	}
}
int main()
{
//	freopen("1.in","r",stdin);
	scanf("%lld%lld",&a,&b);
	for(int i=1;i<=b;i++)
	{
		scanf("%lld%lld",&q,&w);
		++q,++w;
		qu[q].push_back(w);
		qu[w].push_back(q);
	}
	dfs(1,0);
	long long mxx=0;
	for(int i=1;i<=a;i++) mxx=max(mxx,de[i]);
	if(mxx==a-1)
	{
		int tt=1;
		st[++cn]=tt;
		for(int i=1;i<a;i++)
		{
			tt=qu1[tt][0];
			st[++cn]=tt;
		}
		printf("%lld\n",a+1);
		for(int i=1;i<=a+1;i++)
		{
			if(i&1)
			{
				for(int j=1;j<=cn;j++)
				{
					d[st[j]]=(j+1)/2;
				}
			}
			else
			{
				for(int j=1;j<=cn;j++)
				{
					d[st[j]]=(j+2)/2;
				}
			}
			for(int j=1;j<=a;j++) printf("%lld ",d[j]);printf("\n");
		}
	}
	else
	{
		rt=1;
		for(int i=1;i<=a;i++)
		{
			if(qu1[i].size()>1)
			{
				rt=i;break;
			}
		}
		for(int i=1;i<=a;i++) v[i]=0;
		dfs2(rt,0);
		dfs1(rt,0);
		dfs3(rt);
		work(rt);
		cn=0;
		for(int i=0;i<qu3[rt].size();i++) st[++cn]=qu3[rt][i];st[cn+1]=st[1];
		for(int i=1;i<=a;i++) d[i]=i;
		for(int i=1;i<=cn;i++) d[st[i]]=0;
		for(int i=1;i<=cn;i++)
		{
			for(int j=1;j<si[st[i+1]];j++)
			{
				tmp.clear();
				for(int j=0;j<a;j++)
				{
					if(j+1==rt||j+1==st[i]) tmp.push_back(rt);
					else tmp.push_back(j+1);
				}
				ans[++cnn]=tmp;
				get(st[i+1]);
				work(rt);
				for(int k=1;k<=cn;k++) d[st[k]]=0;
			}
		}
		dfs4(rt);
		printf("%lld\n",cnn);
		for(int i=1;i<=cnn;i++)
		{
			for(int j=0;j<a;j++) printf("%lld ",ans[i][j]);
			printf("\n");
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 3ms
memory: 12128kb

input:

2 1
0 1

output:

3
1 1 
1 2 
1 1 

result:

points 1.0

Test #2:

score: 10
Accepted
time: 8ms
memory: 16240kb

input:

3 2
0 1
0 2

output:

5
1 1 1 
1 1 3 
1 1 3 
1 2 1 
1 2 1 

result:

points 1.0

Test #3:

score: 10
Accepted
time: 3ms
memory: 16232kb

input:

4 3
0 1
0 2
0 3

output:

7
1 1 1 1 
1 1 3 4 
1 1 3 4 
1 2 1 4 
1 2 1 4 
1 2 3 1 
1 2 3 1 

result:

points 1.0

Test #4:

score: 10
Accepted
time: 4ms
memory: 16316kb

input:

99 98
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 26
0 27
0 28
0 29
0 30
0 31
0 32
0 33
0 34
0 35
0 36
0 37
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 58
0 59
0 60
0 6...

output:

197
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
1 1 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 3...

result:

points 1.0

Test #5:

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

input:

100 99
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 26
0 27
0 28
0 29
0 30
0 31
0 32
0 33
0 34
0 35
0 36
0 37
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 58
0 59
0 60
0 ...

output:

199
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
1 1 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...

result:

points 1.0

Subtask #2:

score: 13
Accepted

Test #6:

score: 13
Accepted
time: 6ms
memory: 12136kb

input:

2 1
0 1

output:

3
1 1 
1 2 
1 1 

result:

points 1.0

Test #7:

score: 13
Accepted
time: 6ms
memory: 12172kb

input:

3 3
1 2
0 1
0 2

output:

4
1 1 2 
1 2 2 
1 1 2 
1 2 2 

result:

points 1.0

Test #8:

score: 13
Accepted
time: 3ms
memory: 12044kb

input:

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

output:

5
1 1 2 2 
1 2 3 2 
1 1 2 2 
1 2 3 2 
1 1 2 2 

result:

points 1.0

Test #9:

score: 13
Accepted
time: 3ms
memory: 12108kb

input:

10 45
4 9
2 8
5 9
1 2
2 9
4 5
5 7
6 7
1 3
1 9
3 4
0 3
4 7
0 6
5 6
7 9
4 8
6 8
0 5
1 8
3 9
1 6
6 9
4 6
0 8
2 3
0 4
0 9
0 7
3 6
0 2
2 5
3 7
3 5
7 8
5 8
8 9
0 1
2 7
1 7
1 4
2 6
2 4
3 8
1 5

output:

11
1 2 2 1 3 4 5 5 3 4 
1 2 3 2 4 5 6 5 3 4 
1 2 2 1 3 4 5 5 3 4 
1 2 3 2 4 5 6 5 3 4 
1 2 2 1 3 4 5 5 3 4 
1 2 3 2 4 5 6 5 3 4 
1 2 2 1 3 4 5 5 3 4 
1 2 3 2 4 5 6 5 3 4 
1 2 2 1 3 4 5 5 3 4 
1 2 3 2 4 5 6 5 3 4 
1 2 2 1 3 4 5 5 3 4 

result:

points 1.0

Test #10:

score: 13
Accepted
time: 7ms
memory: 12176kb

input:

15 105
4 10
8 13
0 12
11 12
2 13
8 14
6 10
0 4
8 12
2 12
1 13
5 9
2 8
7 10
6 13
0 13
9 13
7 11
3 13
0 3
4 7
5 13
7 13
0 7
0 11
0 8
0 2
2 4
2 6
6 9
0 1
9 11
1 9
3 14
3 4
10 11
5 10
0 9
3 9
6 11
2 10
5 6
2 5
1 14
6 8
9 12
2 11
9 10
5 12
5 14
4 14
7 14
5 8
5 7
1 12
0 14
7 9
3 11
1 8
0 10
1 3
8 9
4 6
10...

output:

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

result:

points 1.0

Test #11:

score: 13
Accepted
time: 7ms
memory: 12116kb

input:

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

output:

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

result:

points 1.0

Test #12:

score: 13
Accepted
time: 7ms
memory: 12052kb

input:

40 780
21 24
11 32
12 27
19 20
3 35
25 35
32 35
27 33
0 24
1 3
1 29
14 25
8 30
24 31
14 32
7 12
5 31
28 35
7 10
18 24
13 32
1 26
3 4
10 30
14 38
22 24
9 31
5 10
17 32
2 34
28 39
3 38
13 34
6 10
0 6
9 25
11 14
13 20
10 20
18 28
6 33
34 35
29 33
16 39
4 38
3 24
20 29
17 18
33 36
13 37
24 27
12 33
5 29...

output:

41
1 6 13 5 17 16 20 8 10 19 9 3 8 12 4 18 13 2 15 11 10 2 19 20 1 4 16 7 14 6 9 15 3 7 12 5 18 11 17 14 
1 6 13 6 18 16 20 9 10 20 9 4 8 12 4 19 14 3 15 11 11 2 19 21 2 5 17 8 15 7 10 16 3 7 13 5 18 12 17 14 
1 6 13 5 17 16 20 8 10 19 9 3 8 12 4 18 13 2 15 11 10 2 19 20 1 4 16 7 14 6 9 15 3 7 12 5 ...

result:

points 1.0

Test #13:

score: 13
Accepted
time: 7ms
memory: 12104kb

input:

50 1225
6 10
14 36
0 34
7 23
22 31
18 34
2 19
13 21
0 46
0 11
2 43
2 11
13 20
13 19
7 39
35 37
9 17
31 38
13 40
7 28
2 41
20 46
25 36
12 39
1 37
21 42
33 48
10 24
13 26
26 37
0 47
17 19
1 28
28 40
15 40
11 22
10 19
24 28
12 28
19 40
6 12
13 48
20 37
11 46
8 19
5 24
16 28
15 47
31 34
11 21
28 33
14 1...

output:

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

result:

points 1.0

Test #14:

score: 13
Accepted
time: 5ms
memory: 12188kb

input:

100 4950
24 39
27 46
11 71
57 65
3 8
84 97
74 87
17 49
12 72
1 4
22 83
29 42
28 65
39 89
29 92
26 78
45 53
18 44
33 43
14 98
50 66
21 95
32 67
21 33
21 80
59 77
70 85
13 16
0 41
31 65
51 80
22 80
30 79
55 75
54 82
29 57
72 97
31 85
86 87
60 90
1 17
65 81
13 15
44 71
58 88
65 87
8 31
77 99
4 44
29 43...

output:

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

result:

points 1.0

Subtask #3:

score: 11
Accepted

Test #15:

score: 11
Accepted
time: 7ms
memory: 12136kb

input:

2 1
0 1

output:

3
1 1 
1 2 
1 1 

result:

points 1.0

Test #16:

score: 11
Accepted
time: 3ms
memory: 12048kb

input:

3 2
0 1
1 2

output:

4
1 1 2 
1 2 2 
1 1 2 
1 2 2 

result:

points 1.0

Test #17:

score: 11
Accepted
time: 7ms
memory: 12136kb

input:

4 3
0 1
1 2
2 3

output:

5
1 1 2 2 
1 2 2 3 
1 1 2 2 
1 2 2 3 
1 1 2 2 

result:

points 1.0

Test #18:

score: 11
Accepted
time: 3ms
memory: 12140kb

input:

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

output:

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

result:

points 1.0

Test #19:

score: 11
Accepted
time: 3ms
memory: 12136kb

input:

99 98
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

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

result:

points 1.0

Test #20:

score: 11
Accepted
time: 3ms
memory: 12072kb

input:

100 99
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
...

output:

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

result:

points 1.0

Test #21:

score: 11
Accepted
time: 7ms
memory: 12060kb

input:

64 63
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

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

result:

points 1.0

Subtask #4:

score: 0
Memory Limit Exceeded

Dependency #1:

100%
Accepted

Dependency #3:

100%
Accepted

Test #22:

score: 36
Accepted
time: 7ms
memory: 12172kb

input:

2 1
0 1

output:

3
1 1 
1 2 
1 1 

result:

points 1.0

Test #23:

score: 36
Accepted
time: 7ms
memory: 16240kb

input:

3 2
0 1
0 2

output:

5
1 1 1 
1 1 3 
1 1 3 
1 2 1 
1 2 1 

result:

points 1.0

Test #24:

score: 36
Accepted
time: 7ms
memory: 16096kb

input:

4 3
0 1
0 2
0 3

output:

7
1 1 1 1 
1 1 3 4 
1 1 3 4 
1 2 1 4 
1 2 1 4 
1 2 3 1 
1 2 3 1 

result:

points 1.0

Test #25:

score: 36
Accepted
time: 5ms
memory: 16336kb

input:

99 98
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 26
0 27
0 28
0 29
0 30
0 31
0 32
0 33
0 34
0 35
0 36
0 37
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 58
0 59
0 60
0 6...

output:

197
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
1 1 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 3...

result:

points 1.0

Test #26:

score: 36
Accepted
time: 4ms
memory: 16332kb

input:

100 99
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
0 10
0 11
0 12
0 13
0 14
0 15
0 16
0 17
0 18
0 19
0 20
0 21
0 22
0 23
0 24
0 25
0 26
0 27
0 28
0 29
0 30
0 31
0 32
0 33
0 34
0 35
0 36
0 37
0 38
0 39
0 40
0 41
0 42
0 43
0 44
0 45
0 46
0 47
0 48
0 49
0 50
0 51
0 52
0 53
0 54
0 55
0 56
0 57
0 58
0 59
0 60
0 ...

output:

199
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 
1 1 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...

result:

points 1.0

Test #27:

score: 36
Accepted
time: 3ms
memory: 12132kb

input:

3 2
0 1
1 2

output:

4
1 1 2 
1 2 2 
1 1 2 
1 2 2 

result:

points 1.0

Test #28:

score: 36
Accepted
time: 3ms
memory: 12124kb

input:

4 3
0 1
1 2
2 3

output:

5
1 1 2 2 
1 2 2 3 
1 1 2 2 
1 2 2 3 
1 1 2 2 

result:

points 1.0

Test #29:

score: 36
Accepted
time: 3ms
memory: 12140kb

input:

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

output:

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

result:

points 1.0

Test #30:

score: 36
Accepted
time: 3ms
memory: 12056kb

input:

99 98
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

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

result:

points 1.0

Test #31:

score: 36
Accepted
time: 4ms
memory: 12132kb

input:

100 99
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
...

output:

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

result:

points 1.0

Test #32:

score: 36
Accepted
time: 3ms
memory: 12140kb

input:

64 63
0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9
9 10
10 11
11 12
12 13
13 14
14 15
15 16
16 17
17 18
18 19
19 20
20 21
21 22
22 23
23 24
24 25
25 26
26 27
27 28
28 29
29 30
30 31
31 32
32 33
33 34
34 35
35 36
36 37
37 38
38 39
39 40
40 41
41 42
42 43
43 44
44 45
45 46
46 47
47 48
48 49
49 50
50 51
51 52
5...

output:

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

result:

points 1.0

Test #33:

score: 0
Memory Limit Exceeded

input:

5 4
2 1
3 2
4 1
1 0

output:


result:


Subtask #5:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Dependency #4:

0%