QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#373136#8310. Fixing Networkskevinyang#AC ✓14ms8720kbC++171.6kb2024-04-01 03:34:432024-04-01 03:34:44

Judging History

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

  • [2024-04-01 03:34:44]
  • 评测
  • 测评结果:AC
  • 用时:14ms
  • 内存:8720kb
  • [2024-04-01 03:34:43]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
int fix(int x, int y){
	x%=y;
	x+=y;
	x%=y;
	return x;
}
signed main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	int n,d,c;
	cin >> n >> d >> c;
	int cur = 1;
	if(d==0){
		if(c==n){
			cout << "Yes\n";
			for(int i = 0; i<n; i++){
				cout << '\n';
			}
		}
		else{
			cout << "No\n";
		}
		return 0;
	}
	if(d==1){
		if(c*2 == n){
			cout << "Yes\n";
			for(int i = 1; i<=n; i++){
				if(i%2==1)cout << i+1 << '\n';
				else cout << i-1 << '\n';
			}
			return 0;
		}
		else{
			cout << "No\n";
			return 0;
		}
	}
	if(d%2==1 && n%2==1){
		cout << "No\n";
		return 0;
	}
	if((d+1)*c>n){
		cout << "No\n";
		return 0;
	}
	vector<vector<int>>ans(n+1);
	while(c>1){
		if(cur+d>n){
			cout << "No\n";
			return 0;
		}
		for(int i = cur; i<=cur+d; i++){
			for(int j = cur; j<=cur+d; j++){
				if(i==j)continue;
				ans[i].push_back(j);
			}
		}
		c--;
		cur+=d+1;
	}

	int rem = n-cur+1;
	if(d%2==1&&rem%2==1){
		cout << "No\n";
		return 0;
	}
	if(rem<=d){
		cout << "No\n";
		return 0;
	}
	if(d%2==1){
		for(int i = 0; i<rem/2; i++){
			ans[i+cur].push_back(i+cur+rem/2);
			ans[i+cur+rem/2].push_back(i+cur);
		}
	}
	for(int i = 1; i<=d/2; i++){
		for(int j = 0; j<rem; j++){
			ans[j+cur].push_back(fix(j+i,rem)+cur);
			ans[fix(j+i,rem)+cur].push_back(j+cur);
		}
	}
	cout << "Yes\n";
	for(int i = 1; i<=n; i++){
		sort(ans[i].begin(),ans[i].end());
		for(int j = 0; j<d; j++){
			cout << ans[i][j];
			if(j+1<d)cout << ' ';
		}
		cout << '\n';
	}
	

	return 0;
}

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

详细

Test #1:

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

input:

12 3 2

output:

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

result:

ok n=12 d=3 c=2

Test #2:

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

input:

3 2 2

output:

No

result:

ok n=3 d=2 c=2

Test #3:

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

input:

1 0 1

output:

Yes


result:

ok n=1 d=0 c=1

Test #4:

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

input:

2 0 1

output:

No

result:

ok n=2 d=0 c=1

Test #5:

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

input:

2 0 2

output:

Yes



result:

ok n=2 d=0 c=2

Test #6:

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

input:

3 0 2

output:

No

result:

ok n=3 d=0 c=2

Test #7:

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

input:

100000 0 100000

output:

Yes








































































































































































































































































































...

result:

ok n=100000 d=0 c=100000

Test #8:

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

input:

2 1 1

output:

Yes
2
1

result:

ok n=2 d=1 c=1

Test #9:

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

input:

2 1 2

output:

No

result:

ok n=2 d=1 c=2

Test #10:

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

input:

3 1 1

output:

No

result:

ok n=3 d=1 c=1

Test #11:

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

input:

3 1 2

output:

No

result:

ok n=3 d=1 c=2

Test #12:

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

input:

3 1 3

output:

No

result:

ok n=3 d=1 c=3

Test #13:

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

input:

4 1 1

output:

No

result:

ok n=4 d=1 c=1

Test #14:

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

input:

4 1 2

output:

Yes
2
1
4
3

result:

ok n=4 d=1 c=2

Test #15:

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

input:

4 1 3

output:

No

result:

ok n=4 d=1 c=3

Test #16:

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

input:

4 1 4

output:

No

result:

ok n=4 d=1 c=4

Test #17:

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

input:

100000 1 50000

output:

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

result:

ok n=100000 d=1 c=50000

Test #18:

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

input:

3 2 1

output:

Yes
2 3
1 3
1 2

result:

ok n=3 d=2 c=1

Test #19:

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

input:

4 2 1

output:

Yes
2 4
1 3
2 4
1 3

result:

ok n=4 d=2 c=1

Test #20:

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

input:

6 2 1

output:

Yes
2 6
1 3
2 4
3 5
4 6
1 5

result:

ok n=6 d=2 c=1

Test #21:

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

input:

6 2 2

output:

Yes
2 3
1 3
1 2
5 6
4 6
4 5

result:

ok n=6 d=2 c=2

Test #22:

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

input:

100000 2 1

output:

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

result:

ok n=100000 d=2 c=1

Test #23:

score: 0
Accepted
time: 14ms
memory: 8720kb

input:

100000 2 316

output:

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

result:

ok n=100000 d=2 c=316

Test #24:

score: 0
Accepted
time: 14ms
memory: 8556kb

input:

100000 2 33333

output:

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

result:

ok n=100000 d=2 c=33333

Test #25:

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

input:

4 3 1

output:

Yes
2 3 4
1 3 4
1 2 4
1 2 3

result:

ok n=4 d=3 c=1

Test #26:

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

input:

4 3 2

output:

No

result:

ok n=4 d=3 c=2

Test #27:

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

input:

8 3 1

output:

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

result:

ok n=8 d=3 c=1

Test #28:

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

input:

8 3 2

output:

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

result:

ok n=8 d=3 c=2

Test #29:

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

input:

9 3 1

output:

No

result:

ok n=9 d=3 c=1

Test #30:

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

input:

9 3 2

output:

No

result:

ok n=9 d=3 c=2

Test #31:

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

input:

66666 3 1

output:

Yes
2 33334 66666
1 3 33335
2 4 33336
3 5 33337
4 6 33338
5 7 33339
6 8 33340
7 9 33341
8 10 33342
9 11 33343
10 12 33344
11 13 33345
12 14 33346
13 15 33347
14 16 33348
15 17 33349
16 18 33350
17 19 33351
18 20 33352
19 21 33353
20 22 33354
21 23 33355
22 24 33356
23 25 33357
24 26 33358
25 27 3335...

result:

ok n=66666 d=3 c=1

Test #32:

score: 0
Accepted
time: 14ms
memory: 7960kb

input:

66666 3 16666

output:

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

result:

ok n=66666 d=3 c=16666

Test #33:

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

input:

20000 10 1

output:

Yes
2 3 4 5 6 19996 19997 19998 19999 20000
1 3 4 5 6 7 19997 19998 19999 20000
1 2 4 5 6 7 8 19998 19999 20000
1 2 3 5 6 7 8 9 19999 20000
1 2 3 4 6 7 8 9 10 20000
1 2 3 4 5 7 8 9 10 11
2 3 4 5 6 8 9 10 11 12
3 4 5 6 7 9 10 11 12 13
4 5 6 7 8 10 11 12 13 14
5 6 7 8 9 11 12 13 14 15
6 7 8 9 10 12 13...

result:

ok n=20000 d=10 c=1

Test #34:

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

input:

20000 10 100

output:

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

result:

ok n=20000 d=10 c=100

Test #35:

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

input:

20000 10 1818

output:

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

result:

ok n=20000 d=10 c=1818

Test #36:

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

input:

18180 11 1

output:

Yes
2 3 4 5 6 9091 18176 18177 18178 18179 18180
1 3 4 5 6 7 9092 18177 18178 18179 18180
1 2 4 5 6 7 8 9093 18178 18179 18180
1 2 3 5 6 7 8 9 9094 18179 18180
1 2 3 4 6 7 8 9 10 9095 18180
1 2 3 4 5 7 8 9 10 11 9096
2 3 4 5 6 8 9 10 11 12 9097
3 4 5 6 7 9 10 11 12 13 9098
4 5 6 7 8 10 11 12 13 14 9...

result:

ok n=18180 d=11 c=1

Test #37:

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

input:

18180 11 100

output:

Yes
2 3 4 5 6 7 8 9 10 11 12
1 3 4 5 6 7 8 9 10 11 12
1 2 4 5 6 7 8 9 10 11 12
1 2 3 5 6 7 8 9 10 11 12
1 2 3 4 6 7 8 9 10 11 12
1 2 3 4 5 7 8 9 10 11 12
1 2 3 4 5 6 8 9 10 11 12
1 2 3 4 5 6 7 9 10 11 12
1 2 3 4 5 6 7 8 10 11 12
1 2 3 4 5 6 7 8 9 11 12
1 2 3 4 5 6 7 8 9 10 12
1 2 3 4 5 6 7 8 9 10 11...

result:

ok n=18180 d=11 c=100

Test #38:

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

input:

18180 11 1515

output:

Yes
2 3 4 5 6 7 8 9 10 11 12
1 3 4 5 6 7 8 9 10 11 12
1 2 4 5 6 7 8 9 10 11 12
1 2 3 5 6 7 8 9 10 11 12
1 2 3 4 6 7 8 9 10 11 12
1 2 3 4 5 7 8 9 10 11 12
1 2 3 4 5 6 8 9 10 11 12
1 2 3 4 5 6 7 9 10 11 12
1 2 3 4 5 6 7 8 10 11 12
1 2 3 4 5 6 7 8 9 11 12
1 2 3 4 5 6 7 8 9 10 12
1 2 3 4 5 6 7 8 9 10 11...

result:

ok n=18180 d=11 c=1515

Test #39:

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

input:

101 100 1

output:

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

result:

ok n=101 d=100 c=1

Test #40:

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

input:

2000 100 10

output:

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

result:

ok n=2000 d=100 c=10

Test #41:

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

input:

2000 100 19

output:

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

result:

ok n=2000 d=100 c=19

Test #42:

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

input:

1980 101 1

output:

Yes
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 991 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 ...

result:

ok n=1980 d=101 c=1

Test #43:

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

input:

1980 101 10

output:

Yes
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 10...

result:

ok n=1980 d=101 c=10

Test #44:

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

input:

1980 101 19

output:

Yes
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 10...

result:

ok n=1980 d=101 c=19

Test #45:

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

input:

447 446 1

output:

Yes
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 10...

result:

ok n=447 d=446 c=1

Extra Test:

score: 0
Extra Test Passed