QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#863681#1351. Koosaga's ProblemSunsetGlow95WA 139ms27096kbC++141.4kb2025-01-19 21:11:592025-01-19 21:12:08

Judging History

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

  • [2025-01-19 21:12:08]
  • 评测
  • 测评结果:WA
  • 用时:139ms
  • 内存:27096kb
  • [2025-01-19 21:11:59]
  • 提交

answer

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

const int MXN = 250005;
int N, M, head[MXN], to[MXN << 1], nxt[MXN << 1];
int dfn[MXN], low[MXN], did;
bool dep[MXN];
unsigned tag[MXN], val[MXN << 1], S;
mt19937 rnd(random_device{}());

void dfs(int p, int le) {
  low[p] = dfn[p] = did++;
  for (int e(head[p]); ~e; e = nxt[e]) {
    if (!(e ^ le ^ 1)) continue;
    int q(to[e]);
    if (~dfn[q]) {
      if (dfn[q] < dfn[p]) {
        unsigned v(rnd());
        val[e] = v, tag[p] ^= v, tag[q] ^= v;
        S ^= !(dep[p] ^ dep[q]) * v;
      }
    } else {
      dep[q] = !dep[p];
      dfs(q, e);
      low[p] = min(low[p], low[q]);
      val[e] = tag[q];
      tag[p] ^= tag[q];
    }
  }
}

int main() {
  cin >> N >> M;
  memset(head, -1, sizeof head);
  for (int i(0), x(0), y(0); i != M; ++i) {
    cin >> x >> y, --x, --y;
    to[i << 1] = y, nxt[i << 1] = head[x], head[x] = i << 1;
    to[i << 1 | 1] = x, nxt[i << 1 | 1] = head[y], head[y] = i << 1 | 1;
  }
  memset(dfn, -1, sizeof dfn);
  dfs(0, -1);
  if (!S) {
    cout << "1\n";
    return 0;
  }
  map<int, int> cnt;
  for (int i(0); i != M; ++i) ++cnt[val[i << 1] ^ val[i << 1 | 1]];
  if (cnt[S]) {
    cout << cnt[S] << endl;
  } else {
    long long sum(0);
    vector<pair<int, int>> vec(cnt.begin(), cnt.end());
    for (auto [p, q] : vec)
      sum += q * 1LL * cnt[S ^ p];
    cout << sum / 2 << endl;
  }
  return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 10624kb

input:

3 2
1 2
2 3

output:

1

result:

ok answer is '1'

Test #2:

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

input:

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

output:

3

result:

ok answer is '3'

Test #3:

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

input:

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

output:

0

result:

ok answer is '0'

Test #4:

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

input:

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

output:

2

result:

ok answer is '2'

Test #5:

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

input:

3 3
1 2
2 3
3 1

output:

3

result:

ok answer is '3'

Test #6:

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

input:

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

output:

1

result:

ok answer is '1'

Test #7:

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

input:

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

output:

3

result:

ok answer is '3'

Test #8:

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

input:

4 3
3 4
2 3
1 2

output:

1

result:

ok answer is '1'

Test #9:

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

input:

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

output:

1

result:

ok answer is '1'

Test #10:

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

input:

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

output:

9

result:

ok answer is '9'

Test #11:

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

input:

4 4
2 4
1 3
1 2
1 4

output:

3

result:

ok answer is '3'

Test #12:

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

input:

1000 999
937 938
606 607
767 768
235 236
827 828
894 895
901 902
349 350
217 218
63 64
947 948
128 129
657 658
108 109
253 254
535 536
321 322
261 262
78 79
590 591
625 626
115 116
244 245
610 611
760 761
378 379
268 269
283 284
10 11
596 597
440 441
493 494
107 108
918 919
130 131
621 622
144 145
4...

output:

1

result:

ok answer is '1'

Test #13:

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

input:

1000 999
119 296
688 168
975 848
264 196
488 866
302 56
525 224
983 731
761 476
825 334
840 908
496 697
71 964
877 138
171 426
799 792
861 337
515 368
66 70
825 365
205 55
768 66
17 276
118 415
620 930
166 860
879 155
817 1
495 405
359 579
121 485
961 742
916 704
859 135
302 894
291 97
389 942
618 4...

output:

1

result:

ok answer is '1'

Test #14:

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

input:

1000 999
680 809
34 44
243 877
355 589
273 691
458 643
193 464
198 632
478 570
320 457
309 866
636 721
181 475
278 565
567 616
138 490
335 554
293 663
246 769
765 769
148 694
384 406
689 712
84 879
268 418
239 806
376 827
247 862
576 848
309 926
140 886
750 989
240 701
347 599
227 599
369 441
187 39...

output:

1

result:

ok answer is '1'

Test #15:

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

input:

1000 1176
133 835
227 953
33 449
196 934
171 587
659 790
256 605
72 393
438 601
599 922
177 221
28 84
156 782
17 48
49 302
198 613
142 154
156 601
788 898
295 431
714 982
374 990
394 539
45 837
73 340
203 371
46 239
159 621
26 424
193 249
623 777
43 184
257 308
582 994
419 420
237 895
373 963
206 58...

output:

6

result:

ok answer is '6'

Test #16:

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

input:

1000 1339
451 789
544 936
344 681
87 823
381 404
734 917
427 956
731 802
78 928
21 201
521 783
685 845
526 850
37 124
94 749
222 449
122 463
97 606
26 787
251 806
644 771
39 778
90 924
259 1000
339 938
758 935
100 722
105 762
4 969
254 420
174 969
908 964
36 304
438 444
46 410
267 433
51 942
938 960...

output:

1

result:

ok answer is '1'

Test #17:

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

input:

1000 1802
298 921
626 905
238 766
63 715
257 513
417 926
288 548
414 791
63 220
674 815
327 931
863 977
539 845
25 922
540 570
746 751
504 971
73 238
22 220
166 599
386 970
27 777
478 760
177 380
238 425
425 665
74 143
78 363
5 528
169 814
112 760
449 487
25 761
296 759
34 78
180 782
34 503
453 841
...

output:

825

result:

ok answer is '825'

Test #18:

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

input:

1000 1988
270 957
545 952
218 483
60 416
241 396
395 456
258 340
392 940
56 362
570 582
306 603
659 839
791 881
832 924
487 762
604 993
464 582
67 866
18 603
167 648
359 876
710 756
446 604
171 528
215 807
405 755
70 418
75 425
4 694
712 813
122 912
425 445
25 822
265 296
32 256
174 379
37 276
426 9...

output:

341

result:

ok answer is '341'

Test #19:

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

input:

1000 1032
593 809
799 834
878 896
154 226
625 931
92 334
9 812
878 348
817 948
335 874
38 215
331 978
306 997
614 573
661 614
459 38
6 625
220 364
145 682
435 876
891 601
200 244
228 407
743 915
28 612
174 372
579 730
313 347
445 717
702 836
938 983
655 704
955 981
272 988
123 332
165 305
866 939
14...

output:

422

result:

ok answer is '422'

Test #20:

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

input:

1000 1924
278 453
582 584
221 304
65 800
240 566
396 623
267 566
393 689
59 881
603 738
315 708
711 787
885 895
25 450
522 834
642 930
489 627
74 180
16 312
167 947
373 796
776 972
462 760
174 489
217 836
405 923
76 481
81 509
4 720
779 829
119 648
439 744
24 869
270 965
33 507
177 341
37 943
445 73...

output:

1

result:

ok answer is '1'

Test #21:

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

input:

1000 1991
274 347
551 797
218 772
57 468
235 442
388 740
258 961
387 513
52 289
574 876
304 348
669 746
780 872
820 909
500 646
621 744
477 857
62 979
19 688
159 350
361 528
719 821
452 583
166 633
217 261
398 587
65 190
69 405
2 794
723 751
110 890
421 637
26 306
268 514
33 212
169 339
36 225
424 9...

output:

1

result:

ok answer is '1'

Test #22:

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

input:

1000 1928
84 196
802 973
25 622
803 916
108 189
419 440
814 950
688 903
525 530
333 688
442 953
720 991
489 688
465 688
36 860
128 785
89 419
98 291
958 980
187 546
364 733
615 780
243 642
438 518
48 706
452 952
35 130
102 641
718 875
451 592
341 443
564 632
164 719
325 392
253 618
154 261
510 688
1...

output:

1

result:

ok answer is '1'

Test #23:

score: 0
Accepted
time: 36ms
memory: 10020kb

input:

100000 99999
89366 91622
12603 89366
86750 89366
8842 89366
14641 89366
41203 89366
31920 89366
89366 96734
28360 89366
48647 89366
85444 89366
75710 89366
36384 89366
6809 89366
89366 99332
32985 89366
48165 89366
57853 89366
73019 89366
32883 89366
20435 89366
63504 89366
46656 89366
57078 89366
6...

output:

1

result:

ok answer is '1'

Test #24:

score: 0
Accepted
time: 46ms
memory: 15408kb

input:

100000 99999
71282 97287
6507 99996
63733 64001
4506 60541
7606 92192
23327 63373
17503 21051
81910 97724
15366 81994
28382 68815
61930 90677
50752 70896
20255 67892
3458 79406
91827 97753
18154 40474
28047 97399
35085 83025
48103 83796
18096 73695
10801 27327
39595 42221
27005 46333
34491 51621
446...

output:

1

result:

ok answer is '1'

Test #25:

score: 0
Accepted
time: 37ms
memory: 11360kb

input:

100000 100000
52047 59665
59665 69113
59665 83945
13174 59665
59665 81134
59665 77600
27421 59665
59665 74469
59665 93945
59665 96712
32872 59665
59665 74329
59665 65436
59665 75171
59665 77952
59665 64008
59665 97796
14487 59665
59665 97693
59665 75034
19220 59665
59665 98010
4435 59665
10973 59665...

output:

3

result:

ok answer is '3'

Test #26:

score: 0
Accepted
time: 44ms
memory: 17992kb

input:

100000 100000
30703 90118
44336 63774
59821 74990
6812 21932
56433 89435
52608 79768
14774 22164
49427 53632
75357 95298
81814 95624
18048 91245
49308 51112
41129 48169
50151 93302
52995 82860
39929 79509
85110 97680
7513 27749
84734 92761
50016 90975
10100 29613
85899 93623
2240 68812
5629 22277
35...

output:

3

result:

ok answer is '3'

Test #27:

score: 0
Accepted
time: 38ms
memory: 13508kb

input:

100000 100000
30801 97154
44545 92438
60073 67655
6844 66945
56812 76338
52854 78197
14849 43566
49691 51780
75319 81189
81710 83599
18136 73974
49554 91764
41278 51954
50388 87338
53197 92982
40075 50827
84981 96946
7545 14303
84669 94070
50264 80902
10143 34482
85760 88357
2253 56982
5668 94218
35...

output:

1

result:

ok answer is '1'

Test #28:

score: 0
Accepted
time: 43ms
memory: 17808kb

input:

100000 100000
30767 54574
44372 55699
59799 72152
6805 97532
56345 84698
52578 83040
14767 17335
49396 89978
75314 81383
81872 96865
18041 35132
49275 66296
41136 94667
50109 85455
52930 55282
39926 51211
85260 96775
7503 55024
84902 93487
49980 73902
10088 84202
86028 97726
2233 71708
5623 28086
35...

output:

99999

result:

ok answer is '99999'

Test #29:

score: 0
Accepted
time: 43ms
memory: 17796kb

input:

100000 100000
30755 85428
44468 93421
59964 92461
6832 76372
56581 92396
52662 96850
14822 74330
49499 65067
75573 91512
82096 98550
18106 42397
49356 93201
41234 42805
50157 89066
53042 61629
40003 68235
85442 94576
7545 14446
85137 89150
50022 53680
10140 58315
86140 87230
2251 85077
5664 66161
35...

output:

1

result:

ok answer is '1'

Test #30:

score: 0
Accepted
time: 29ms
memory: 11312kb

input:

100000 99999
1 91622
1 12604
1 86751
1 8843
1 14642
1 41204
1 31921
1 96734
1 28361
1 48648
1 85445
1 75711
1 36385
1 6810
1 99332
1 32986
1 48166
1 57854
1 73020
1 32884
1 20436
1 63505
1 46657
1 57079
1 69281
1 9861
1 71914
1 75015
1 428
1 28193
1 8160
1 423
1 570
1 37464
1 88808
1 92439
1 99644
1...

output:

1

result:

ok answer is '1'

Test #31:

score: 0
Accepted
time: 40ms
memory: 17764kb

input:

100000 99999
91621 91622
12603 12604
86750 86751
8842 8843
14641 14642
41203 41204
31920 31921
96733 96734
28360 28361
48647 48648
85444 85445
75710 75711
36384 36385
6809 6810
99331 99332
32985 32986
48165 48166
57853 57854
73019 73020
32883 32884
20435 20436
63504 63505
46656 46657
57078 57079
692...

output:

1

result:

ok answer is '1'

Test #32:

score: 0
Accepted
time: 33ms
memory: 14884kb

input:

80000 80100
13286 16329
24065 70002
52355 57389
37245 43482
8840 25494
4906 60032
41115 55707
28608 78206
39841 44270
38935 67724
11316 18353
57632 65172
1744 36717
8868 76871
43070 46272
25385 42621
16159 73810
12402 57325
70208 79471
39418 68162
53789 74306
70143 75178
13873 64120
50415 73417
1163...

output:

39899

result:

ok answer is '39899'

Test #33:

score: 0
Accepted
time: 40ms
memory: 11924kb

input:

100000 99999
71031 77964
6512 55622
63593 80053
4533 13744
7596 33726
23296 83405
17462 62129
81827 95744
15397 50270
28269 68836
61797 78346
50650 59379
20128 83438
3494 27599
91809 91961
18083 77637
27926 85255
35024 79875
48040 65352
18029 63639
10796 34096
39479 60599
26950 61478
34422 36660
445...

output:

1

result:

ok answer is '1'

Test #34:

score: 0
Accepted
time: 43ms
memory: 14756kb

input:

100000 100100
3219 47727
82510 87616
34527 95559
51772 81628
25606 43364
16608 98054
12305 40411
13702 60209
18874 56075
64069 68780
12628 53125
22764 58332
3946 29805
9985 30781
19125 34047
53814 72897
27669 36609
30254 96597
88307 90955
94803 99930
33463 42386
22761 68939
22937 40625
73957 89169
5...

output:

1

result:

ok answer is '1'

Test #35:

score: 0
Accepted
time: 47ms
memory: 14116kb

input:

100000 100100
3192 69847
82628 86144
34584 82913
51799 69422
25591 98822
16536 47671
12259 98927
13664 92773
18789 62163
64032 85891
12600 94482
22740 83198
3909 25631
9941 95009
19036 98184
53856 98302
27677 73503
30275 42880
88467 95690
95277 97614
33518 61897
22738 32636
22911 95932
73953 76551
5...

output:

19676

result:

ok answer is '19676'

Test #36:

score: 0
Accepted
time: 45ms
memory: 15656kb

input:

100000 100100
3245 35185
82655 91380
34544 44074
51864 84518
25635 42996
16561 26376
12285 66381
13685 59022
18827 82358
64133 74224
12624 25164
22733 88104
3946 56773
9942 25895
19078 38891
53993 74263
27663 86511
30214 67752
88507 94773
94988 98737
33452 54813
22730 97029
22897 42466
74001 91609
5...

output:

55249

result:

ok answer is '55249'

Test #37:

score: 0
Accepted
time: 41ms
memory: 14044kb

input:

100000 100100
3187 82234
82779 87397
34522 42196
51678 95389
25561 70821
16536 56652
12253 17066
13689 79288
18801 94797
63897 92516
12601 65144
22715 28149
3897 68881
9916 21294
19046 75231
53772 86987
27626 62438
30210 33140
88515 95534
94822 98585
33500 47514
22711 88166
22891 50469
73923 89009
5...

output:

1

result:

ok answer is '1'

Test #38:

score: 0
Accepted
time: 39ms
memory: 11940kb

input:

100000 100086
42854 79349
35449 90716
24753 79104
48422 53549
3207 51247
50043 90570
69369 76898
45547 69511
27794 56980
27984 64590
60656 70939
20932 39458
20007 24572
16475 16773
35104 98562
8691 32704
8468 59411
38934 98796
31804 40062
10467 35694
2029 59590
93891 97624
21166 54812
94419 94563
38...

output:

4

result:

ok answer is '4'

Test #39:

score: 0
Accepted
time: 49ms
memory: 12148kb

input:

100000 100100
3175 35751
82677 95396
34483 50051
51619 67979
25584 44543
16574 46319
12266 33146
13697 64508
18843 60636
63880 64592
12609 19737
22767 59740
3878 65570
9926 65822
19086 87768
53679 57893
27681 51713
30190 99403
88203 96811
94815 99355
33427 68879
22763 67711
22946 32672
73817 78915
5...

output:

1

result:

ok answer is '1'

Test #40:

score: 0
Accepted
time: 27ms
memory: 10988kb

input:

100000 99999
1 91622
1 12604
1 86751
1 8843
1 14642
1 41204
1 31921
1 96734
1 28361
1 48648
1 85445
1 75711
1 36385
1 6810
1 99332
1 32986
1 48166
1 57854
1 73020
1 32884
1 20436
1 63505
1 46657
1 57079
1 69281
1 9861
1 71914
1 75015
1 428
1 28193
1 8160
1 423
1 570
1 37464
1 88808
1 92439
1 99644
1...

output:

1

result:

ok answer is '1'

Test #41:

score: 0
Accepted
time: 41ms
memory: 11944kb

input:

100000 99999
70980 79865
6504 49942
63509 81202
4501 7353
7600 81618
23296 48498
17387 34066
81867 84806
15316 38945
28375 85802
61821 83191
50690 57429
20159 48596
3449 89694
91771 99815
18056 63239
28043 45976
35206 39102
48132 75644
17989 72324
10790 94281
39717 84138
26986 51782
34613 67866
4471...

output:

1

result:

ok answer is '1'

Test #42:

score: 0
Accepted
time: 60ms
memory: 16376kb

input:

100000 108983
21404 28497
13689 70925
71958 74068
2781 97683
46835 69049
17997 38493
21756 76722
6630 95872
639 58783
28329 31299
24091 35440
40913 82273
38109 62691
4771 19453
62755 70375
74893 92009
9025 17849
1191 99151
51850 69612
40615 60737
69125 86355
70084 86364
64153 97666
53694 77948
27564...

output:

38180

result:

ok answer is '38180'

Test #43:

score: 0
Accepted
time: 52ms
memory: 15948kb

input:

100000 109000
27707 68530
592 32866
30670 38748
27262 52892
51114 94895
34640 93889
12424 22032
41275 98947
7912 29103
11149 40882
14235 47607
16048 49440
2472 25164
10378 81306
37728 65110
42214 62280
18595 94650
16802 98910
37660 82493
41491 89104
13152 84110
4558 90674
62853 70767
48530 50013
128...

output:

24969

result:

ok answer is '24969'

Test #44:

score: 0
Accepted
time: 76ms
memory: 16312kb

input:

100000 190844
13585 67402
32308 38320
31641 32411
12059 42183
40368 46576
49145 83830
23435 67024
48554 65783
360 41809
49690 61779
44873 85071
29405 54993
36235 90782
2419 68841
14362 83379
66794 96037
48566 60148
5026 91369
22289 94901
54891 55832
76527 86739
674 17495
26947 52337
17013 59294
3129...

output:

1

result:

ok answer is '1'

Test #45:

score: 0
Accepted
time: 117ms
memory: 24736kb

input:

100000 194584
87732 90808
42047 76222
13420 43242
9782 50201
6923 34878
2663 21591
55883 66067
54331 88112
88915 94705
57706 65336
59704 60396
34732 60683
21225 51922
55132 74153
3067 11247
5344 88565
39971 87907
63857 72342
37163 98822
20807 94565
51333 59071
26480 37289
4289 60980
18177 55294
3432...

output:

43360

result:

ok answer is '43360'

Test #46:

score: 0
Accepted
time: 127ms
memory: 21672kb

input:

100000 199939
70416 73740
75586 75638
71450 85096
63327 65018
48442 90771
8530 15589
37382 38390
37283 63532
16780 20903
24930 56513
65124 85977
44246 99362
45945 82907
4014 15561
31426 47134
31466 52535
282 40706
6200 15065
21886 28276
905 39852
46000 54889
73239 76576
19036 55173
17378 53119
13358...

output:

17389

result:

ok answer is '17389'

Test #47:

score: 0
Accepted
time: 83ms
memory: 16444kb

input:

100000 199984
7447 46857
9557 11457
7059 72433
28315 41209
10160 13204
62259 79002
7077 79377
88037 94214
1186 96505
31099 88035
31748 66238
11862 38368
71669 92960
72455 90720
7839 51902
1163 77623
58255 83799
52348 98051
39071 52755
17802 44490
32995 36579
3751 91493
187 77278
49537 75024
17719 80...

output:

1

result:

ok answer is '1'

Test #48:

score: -100
Wrong Answer
time: 139ms
memory: 27096kb

input:

100000 181221
35628 99578
16271 95829
40 50284
78559 91482
27156 66558
12769 77608
72263 86992
72285 96603
37106 49734
38810 92181
53380 79666
22183 33285
44440 58562
53515 78880
54362 68580
9625 44440
36721 81728
29548 42240
42359 96705
23802 97034
4824 63574
38313 83808
10981 80801
54362 82136
307...

output:

6

result:

wrong answer expected '0', found '6'