QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#536269#3015. Double CliqueJooDdaeAC ✓22ms8960kbC++201.0kb2024-08-28 21:43:452024-08-28 21:43:46

Judging History

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

  • [2024-08-28 21:43:46]
  • 评测
  • 测评结果:AC
  • 用时:22ms
  • 内存:8960kb
  • [2024-08-28 21:43:45]
  • 提交

answer

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

const int mod = 1e9 + 7;

int n, m, d[200200], c[200200];

ll f[200200], r[200200];

ll pw(ll n, ll k) {
    ll re = 1, g = n;
    while(k) {
        if(k & 1) re = (re * g) % mod;
        k >>= 1, g = g * g % mod;
    }
    return re;
}

ll C(ll n, ll k) {
    return f[n] * pw(f[k], mod-2) % mod * pw(f[n-k], mod-2) % mod;
}

int main() {
    cin.tie(0)->sync_with_stdio(0);
    cin >> n >> m;
    vector<array<int, 2>> e(m);
    for(auto &[x, y] : e) cin >> x >> y, d[x]++, d[y]++;
    int mn = n;
    for(auto [x, y] : e) {
        if(d[x] > d[y]) swap(x, y);
        mn = min(mn, d[y]);
    }
    f[0] = 1;
    for(int i=1;i<=n;i++) c[d[i]]++, f[i] = f[i-1]*i%mod;

    ll N = n, M = m+m;
    ll ans = M == N*(N-1);

    for(int i=0;i<n;i++) {
        for(int j=1;j<=c[i];j++) {
            N--, M -= i;
            if(M-N*(N-1) == m+m-M) ans = (ans + C(c[i], j)) % mod;
        }
    }
    cout << ans;
}

详细

Test #1:

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

input:

3 3
1 3
1 2
2 3

output:

4

result:

ok 1 number(s): "4"

Test #2:

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

input:

4 3
2 4
3 4
2 3

output:

4

result:

ok 1 number(s): "4"

Test #3:

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

input:

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

output:

3

result:

ok 1 number(s): "3"

Test #4:

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

input:

3 2
1 3
1 2

output:

3

result:

ok 1 number(s): "3"

Test #5:

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

input:

2 1
1 2

output:

3

result:

ok 1 number(s): "3"

Test #6:

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

input:

5 10
3 4
1 2
4 5
1 4
1 5
2 5
2 3
1 3
2 4
3 5

output:

6

result:

ok 1 number(s): "6"

Test #7:

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

input:

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

output:

4

result:

ok 1 number(s): "4"

Test #8:

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

input:

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

output:

1

result:

ok 1 number(s): "1"

Test #9:

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

input:

4 4
3 4
1 2
1 3
2 4

output:

0

result:

ok 1 number(s): "0"

Test #10:

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

input:

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

output:

3

result:

ok 1 number(s): "3"

Test #11:

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

input:

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

output:

0

result:

ok 1 number(s): "0"

Test #12:

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

input:

5 9
2 3
4 5
1 3
1 5
1 2
3 4
2 4
3 5
2 5

output:

3

result:

ok 1 number(s): "3"

Test #13:

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

input:

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

output:

11

result:

ok 1 number(s): "11"

Test #14:

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

input:

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

output:

9

result:

ok 1 number(s): "9"

Test #15:

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

input:

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

output:

10

result:

ok 1 number(s): "10"

Test #16:

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

input:

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

output:

11

result:

ok 1 number(s): "11"

Test #17:

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

input:

20 65
3 7
15 19
1 18
7 18
2 19
2 12
7 15
1 20
18 19
1 7
1 6
6 12
2 5
15 18
7 19
12 15
1 8
3 19
6 18
2 20
12 19
12 20
5 6
8 19
2 8
7 20
3 6
8 15
2 15
19 20
15 20
3 5
12 18
2 3
1 19
6 15
3 15
6 20
3 8
3 18
8 12
5 8
5 7
2 6
1 3
18 20
1 5
1 12
2 18
3 12
5 20
5 19
2 7
6 19
8 18
6 8
6 7
5 18
7 8
1 2
5 15
...

output:

3

result:

ok 1 number(s): "3"

Test #18:

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

input:

632 199396
381 425
296 612
69 611
409 458
399 470
151 408
413 439
37 215
94 361
322 565
477 630
112 542
80 357
59 448
239 291
223 618
176 216
307 559
350 417
97 435
351 596
178 325
266 407
508 530
361 398
177 588
103 535
165 386
492 611
219 533
70 557
419 468
257 575
188 447
45 95
30 325
512 574
111...

output:

633

result:

ok 1 number(s): "633"

Test #19:

score: 0
Accepted
time: 18ms
memory: 7656kb

input:

200000 199396
93961 141403
133602 154135
25654 155627
29635 121223
31604 51285
82395 106531
96665 167289
84797 189823
38075 74930
31604 194538
25542 49261
71545 133990
56274 93128
56981 199206
51424 173433
76756 86215
11729 29101
124438 166593
54075 97971
9817 84449
139346 147877
73539 122643
99598 ...

output:

633

result:

ok 1 number(s): "633"

Test #20:

score: 0
Accepted
time: 21ms
memory: 7776kb

input:

200000 199999
29045 99453
29045 171318
29045 155031
29045 34098
29045 98554
3573 29045
29045 56047
29045 112057
29045 184976
29045 95867
29045 141519
29045 41666
11772 29045
29045 89834
2878 29045
29045 86546
29045 82863
29045 116924
13977 29045
29045 74413
29045 50732
29045 147180
29045 169589
2904...

output:

200000

result:

ok 1 number(s): "200000"

Test #21:

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

input:

1236 200000
799 990
133 819
73 482
494 1218
116 180
862 870
814 1128
790 1235
755 1120
449 1010
94 1177
23 459
1102 1214
89 977
231 251
380 1120
204 335
273 1222
303 470
394 761
1158 1190
550 795
149 1098
121 947
184 224
419 599
530 587
490 1189
51 1052
489 555
718 1158
309 1050
73 617
4 315
431 102...

output:

239

result:

ok 1 number(s): "239"

Test #22:

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

input:

540 118502
198 331
455 513
190 266
312 351
96 411
138 431
114 298
188 526
145 213
134 405
417 444
407 442
297 461
70 116
175 333
135 494
236 261
66 294
101 248
25 235
122 144
15 135
120 520
488 493
90 295
225 402
66 114
145 151
94 267
433 445
39 307
347 435
203 269
135 276
40 202
68 493
63 114
1 67
...

output:

234

result:

ok 1 number(s): "234"

Test #23:

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

input:

540 118492
334 352
227 329
406 431
118 435
147 423
62 315
74 297
125 131
215 460
113 480
313 431
19 419
18 535
96 333
281 459
90 324
24 31
391 413
64 104
55 87
77 180
450 486
148 164
219 354
262 411
293 397
35 226
107 405
368 540
1 535
65 140
97 174
197 460
37 242
13 516
89 346
179 467
256 395
306 5...

output:

224

result:

ok 1 number(s): "224"

Test #24:

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

input:

540 118452
124 419
106 517
306 335
469 525
17 21
17 86
206 407
94 397
477 538
68 228
319 485
269 349
30 73
226 469
37 536
3 180
281 284
125 422
43 188
31 118
86 113
499 528
109 139
36 154
75 164
72 306
13 291
20 474
324 474
425 481
270 514
382 390
269 505
1 30
336 486
37 264
109 225
82 485
430 485
4...

output:

189

result:

ok 1 number(s): "189"

Test #25:

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

input:

540 118302
298 424
100 244
23 531
68 139
252 286
222 530
266 534
240 315
117 182
33 256
281 415
162 425
4 359
495 518
95 289
91 407
139 228
137 345
76 539
100 187
106 371
298 433
277 328
10 419
137 402
74 246
68 446
155 202
270 360
211 389
288 461
6 469
35 185
197 381
231 363
214 255
132 540
20 151
...

output:

99

result:

ok 1 number(s): "99"

Test #26:

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

input:

540 118497
455 522
68 405
78 185
68 345
210 256
429 468
111 285
19 193
100 139
165 395
106 140
90 412
96 284
139 445
298 445
119 537
14 281
189 347
1 209
275 488
257 515
77 261
241 444
145 485
178 435
141 360
164 252
27 446
404 405
385 534
188 202
187 299
282 318
174 393
10 268
99 310
269 357
30 39
...

output:

229

result:

ok 1 number(s): "229"

Test #27:

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

input:

540 118405
34 160
214 365
69 273
110 500
456 512
113 151
68 194
271 468
182 498
326 352
64 352
223 278
180 473
106 273
159 321
206 530
218 300
101 440
165 173
325 463
288 408
345 540
414 434
196 478
198 452
228 467
484 522
390 540
14 290
404 469
317 363
84 437
307 328
17 378
298 468
219 251
42 93
14...

output:

156

result:

ok 1 number(s): "156"

Test #28:

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

input:

540 118470
46 129
115 381
223 315
374 479
17 204
86 318
167 407
86 287
217 305
306 532
68 305
255 347
69 285
380 428
194 199
206 335
42 216
60 424
202 368
175 395
384 514
14 33
104 396
309 479
63 75
2 257
275 476
183 419
357 389
166 273
209 465
380 394
121 469
21 202
55 68
112 416
216 403
212 315
13...

output:

203

result:

ok 1 number(s): "203"

Test #29:

score: 0
Accepted
time: 18ms
memory: 8072kb

input:

200000 199386
40855 147845
40217 70238
5742 100723
71562 185438
1658 193490
175171 177758
90477 97133
45258 109753
99957 180784
40217 115537
95901 127548
2477 34579
42194 134784
150986 180459
103519 129156
20524 95201
191705 196175
58223 181710
93293 165835
59021 87064
161147 166160
55280 131198
702...

output:

0

result:

ok 1 number(s): "0"

Test #30:

score: 0
Accepted
time: 17ms
memory: 7520kb

input:

200000 199346
126792 136617
156919 180654
38520 78160
55744 150776
9851 128076
5524 135022
98952 131461
70910 115144
108130 167202
53539 69396
84681 126098
48097 134286
11751 142671
105447 178247
45986 145083
91760 190230
27250 154136
86192 108204
71041 161028
3621 98198
146732 197142
83496 156735
1...

output:

0

result:

ok 1 number(s): "0"

Test #31:

score: 0
Accepted
time: 17ms
memory: 8960kb

input:

200000 199196
55526 114156
75577 85108
1243 17717
76204 108214
44321 135420
99054 175147
44321 104966
168847 179097
168847 178418
39746 160972
54401 135014
99523 188556
104966 157915
162182 188502
77153 165180
21915 69371
68830 72156
94610 125396
78585 104966
124551 149198
53272 135348
16431 34783
9...

output:

0

result:

ok 1 number(s): "0"

Test #32:

score: 0
Accepted
time: 22ms
memory: 8064kb

input:

200000 199391
21662 162236
5146 57210
32661 141996
12772 133819
10186 27004
81084 137288
140690 162162
26253 182203
57210 156003
11425 110912
64785 163228
104297 193062
112701 140401
15899 190962
49417 170227
161381 195854
75322 149936
27038 180902
59912 73075
34702 40405
2060 69332
84073 140259
851...

output:

0

result:

ok 1 number(s): "0"

Test #33:

score: 0
Accepted
time: 18ms
memory: 7500kb

input:

200000 199299
111990 141040
61140 109405
18835 34191
120091 175558
29812 148006
139549 150226
8995 175522
81828 100391
127850 192483
42430 143193
62936 120091
38962 93211
23062 80083
21006 81194
51817 157893
138038 174034
32336 135766
62936 135523
20292 71226
87552 139549
108773 195697
37261 149956
...

output:

0

result:

ok 1 number(s): "0"

Test #34:

score: 0
Accepted
time: 17ms
memory: 7824kb

input:

200000 199364
42048 118832
143987 197593
104101 129249
27933 39954
158325 178315
10702 19825
1966 165331
64434 159266
42828 63597
31895 51467
55513 130550
48057 134754
41672 66773
67353 109311
20675 187970
85794 178315
3896 150028
114965 137145
159478 187028
33276 67376
4045 14903
52704 167236
23533...

output:

0

result:

ok 1 number(s): "0"

Test #35:

score: 0
Accepted
time: 22ms
memory: 7676kb

input:

200000 199995
6981 158301
14233 45394
14233 73452
6981 45707
14233 134244
14233 41468
14233 94555
14233 198184
14233 34697
6981 189816
14233 161528
14233 44457
6981 126018
14233 47792
6981 115660
14233 41146
6981 121171
14233 110337
6981 174593
6981 168567
14233 110078
14233 18735
14233 192474
14233...

output:

99998

result:

ok 1 number(s): "99998"