QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#818110#8310. Fixing Networksdoyo#AC ✓16ms9144kbC++201.9kb2024-12-17 16:28:082024-12-17 16:28:09

Judging History

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

  • [2024-12-17 16:28:09]
  • 评测
  • 测评结果:AC
  • 用时:16ms
  • 内存:9144kb
  • [2024-12-17 16:28:08]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define FOR(i,j,k) for(int i=j;i<=k;++i)
#define For(i,j,k) for(int i=j;i>=k;--i)
#define mid (l+r>>1)
#define lson (x<<1)
#define rson (x<<1|1)
#define int long long
const int N = 2e5 + 111;
vector<int> e[N];
void sol(){
	int n,d,c;
	cin>>n>>d>>c;
	if(d==0){
		if(n==c){
			cout<<"Yes\n";
			FOR(i,1,n) cout<<'\n';
			return;
		}
		else{
			cout<<"No";
			return;
		}
	}
	if((d+1)*c>n){
		cout<<"No";
		return;
	}
	if(d%2==0){
		int m = n-(d+1)*(c-1);
		FOR(i,0,m-1){
			FOR(j,1,d/2){
				e[i+1].push_back((i+j)%m+1);
				e[(i+j)%m+1].push_back(i+1);
			}
		}
		FOR(k,1,c-1){
			int now = (k-1)*(d+1)+m+1;
			FOR(i,0,d){
				FOR(j,1,d/2){
					e[i+now].push_back((i+j)%(d+1)+now);
					e[(i+j)%(d+1)+now].push_back(i+now);
				}
			}
		}
		FOR(i,1,n) sort(e[i].begin(),e[i].end());
		cout<<"Yes\n";
		FOR(i,1,n){
			for(auto num:e[i]){
				cout<<num<<' ';
			}
			cout<<'\n';
		}
	}
	else{
		if(n%2==1){
			cout<<"No";
			return;
		}
		else{
			if(d==1){
				if(n!=c*2){
					cout<<"No\n";
					return;
				} 
				else{
					FOR(i,1,n/2){
						e[i*2-1].push_back(i*2);
						e[i*2].push_back(i*2-1);
					}
				}
			}
			else{
				int m = n-(d+1)*(c-1);
				FOR(i,0,m-1){
					FOR(j,1,d/2){
						e[i+1].push_back((i+j)%m+1);
						e[(i+j)%m+1].push_back(i+1);
					}
				}
				FOR(i,1,m/2){
					e[i].push_back(i+m/2);
					e[i+m/2].push_back(i);
				}
				FOR(k,1,c-1){
					int now = (k-1)*(d+1)+m+1;
					FOR(i,0,d){
						FOR(j,0,d){
							if(i!=j){
								e[i+now].push_back(j+now);
							}
						}
					}
				}
			}
			FOR(i,1,n) sort(e[i].begin(),e[i].end());
			cout<<"Yes\n";
			FOR(i,1,n){
				for(auto num:e[i]){
					cout<<num<<' ';
				}
				cout<<'\n';
			}
		}
	}
}
signed main()
{
    std::cin.tie(0);
    std::cin.sync_with_stdio(0);
    int t=1;
    while(t--){
    	sol();
	}
    return 0;
}
/*
16 0 16 
*/

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

12 3 2

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 
10 11 12 
9 11 12 
9 10 12 
9 10 11 

result:

ok n=12 d=3 c=2

Test #2:

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

input:

3 2 2

output:

No

result:

ok n=3 d=2 c=2

Test #3:

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

input:

1 0 1

output:

Yes


result:

ok n=1 d=0 c=1

Test #4:

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

input:

2 0 1

output:

No

result:

ok n=2 d=0 c=1

Test #5:

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

input:

2 0 2

output:

Yes



result:

ok n=2 d=0 c=2

Test #6:

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

input:

3 0 2

output:

No

result:

ok n=3 d=0 c=2

Test #7:

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

input:

100000 0 100000

output:

Yes








































































































































































































































































































...

result:

ok n=100000 d=0 c=100000

Test #8:

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

input:

2 1 1

output:

Yes
2 
1 

result:

ok n=2 d=1 c=1

Test #9:

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

input:

2 1 2

output:

No

result:

ok n=2 d=1 c=2

Test #10:

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

input:

3 1 1

output:

No

result:

ok n=3 d=1 c=1

Test #11:

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

input:

3 1 2

output:

No

result:

ok n=3 d=1 c=2

Test #12:

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

input:

3 1 3

output:

No

result:

ok n=3 d=1 c=3

Test #13:

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

input:

4 1 1

output:

No

result:

ok n=4 d=1 c=1

Test #14:

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

input:

4 1 2

output:

Yes
2 
1 
4 
3 

result:

ok n=4 d=1 c=2

Test #15:

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

input:

4 1 3

output:

No

result:

ok n=4 d=1 c=3

Test #16:

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

input:

4 1 4

output:

No

result:

ok n=4 d=1 c=4

Test #17:

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

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

result:

ok n=100000 d=1 c=50000

Test #18:

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

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: 1ms
memory: 3572kb

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: 3620kb

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: 3568kb

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: 10ms
memory: 9144kb

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 
4...

result:

ok n=100000 d=2 c=1

Test #23:

score: 0
Accepted
time: 16ms
memory: 9024kb

input:

100000 2 316

output:

Yes
2 99055 
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...

result:

ok n=100000 d=2 c=316

Test #24:

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

input:

100000 2 33333

output:

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

result:

ok n=100000 d=2 c=33333

Test #25:

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

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: 1ms
memory: 3636kb

input:

4 3 2

output:

No

result:

ok n=4 d=3 c=2

Test #27:

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

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: 1ms
memory: 3680kb

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: 1ms
memory: 3680kb

input:

9 3 1

output:

No

result:

ok n=9 d=3 c=1

Test #30:

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

input:

9 3 2

output:

No

result:

ok n=9 d=3 c=2

Test #31:

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

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

result:

ok n=66666 d=3 c=1

Test #32:

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

input:

66666 3 16666

output:

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

result:

ok n=66666 d=3 c=16666

Test #33:

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

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

result:

ok n=20000 d=10 c=1

Test #34:

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

input:

20000 10 100

output:

Yes
2 3 4 5 6 18907 18908 18909 18910 18911 
1 3 4 5 6 7 18908 18909 18910 18911 
1 2 4 5 6 7 8 18909 18910 18911 
1 2 3 5 6 7 8 9 18910 18911 
1 2 3 4 6 7 8 9 10 18911 
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 ...

result:

ok n=20000 d=10 c=100

Test #35:

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

input:

20000 10 1818

output:

Yes
2 3 4 5 6 9 10 11 12 13 
1 3 4 5 6 7 10 11 12 13 
1 2 4 5 6 7 8 11 12 13 
1 2 3 5 6 7 8 9 12 13 
1 2 3 4 6 7 8 9 10 13 
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 
1 4 5 6 7 8 10 11 12 13 
1 2 5 6 7 8 9 11 12 13 
1 2 3 6 7 8 9 10 12 13 
1 2 3 4 7 8 9 10 11 13 
1 2 3 4...

result:

ok n=20000 d=10 c=1818

Test #36:

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

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

result:

ok n=18180 d=11 c=1

Test #37:

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

input:

18180 11 100

output:

Yes
2 3 4 5 6 8497 16988 16989 16990 16991 16992 
1 3 4 5 6 7 8498 16989 16990 16991 16992 
1 2 4 5 6 7 8 8499 16990 16991 16992 
1 2 3 5 6 7 8 9 8500 16991 16992 
1 2 3 4 6 7 8 9 10 8501 16992 
1 2 3 4 5 7 8 9 10 11 8502 
2 3 4 5 6 8 9 10 11 12 8503 
3 4 5 6 7 9 10 11 12 13 8504 
4 5 6 7 8 10 11 12...

result:

ok n=18180 d=11 c=100

Test #38:

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

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

result:

ok n=18180 d=11 c=1515

Test #39:

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

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: 10ms
memory: 5676kb

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 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072...

result:

ok n=2000 d=100 c=10

Test #41:

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

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 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 17...

result:

ok n=2000 d=100 c=19

Test #42:

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

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: 10ms
memory: 5756kb

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 532 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 ...

result:

ok n=1980 d=101 c=10

Test #44:

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

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 73 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 ...

result:

ok n=1980 d=101 c=19

Test #45:

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

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