QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#323905#4829. Mark on a Graphhotboy27030 1ms3992kbC++142.5kb2024-02-10 14:06:262024-02-10 14:06:26

Judging History

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

  • [2024-02-10 14:06:26]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3992kb
  • [2024-02-10 14:06:26]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define pll pair <ll,ll>
#define fi first
#define se second
#define sz(a) (ll((a).size()))
#define BIT(mask,i) (((mask) >> (i))&1LL)
#define MASK(i) (1LL << (i))
ll n,m;
vector <ll> g[1010];
const ll check = 8;
int main(){
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
    cin>>n>>m;
    vector <pll> edge;
    for (ll i = 1;i <= m;i ++){
        ll u,v;
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
        edge.push_back({u,v});
    }
    ll cnt[check]={};
    for (ll i = 1;i <= n;i ++){
        if (sz(g[i])<check)cnt[sz(g[i])]^=1;
    }
    ll sum = 0;
    for (ll i = 0;i < check;i ++)sum += cnt[i];
    if (sum!=0){
        cout<<"mark\n";
        vector <pll> del;
        for (ll i = 0;i < check;i ++){
//            cout<<i<<endl;
            ll sum = 0;
            for (ll j = 1;j <= n;j ++)sum += sz(g[j])==i;
            if (sum%2){
                bool ok = 0;
                for (ll j = 1;j <= n && !ok;j ++){
                    if (sz(g[j])==i+1){
                        for (auto x:g[j]){
                            if (sz(g[x])>i+1){
                                del.push_back({j,x});
//                                cout<<i<<' '<<j<<' '<<x<<' '<<sz(g[j])<<' '<<sz(g[x])<<'\n';
                                for (ll k = 0;k < sz(g[j]);k++){
                                    if (g[j][k]==x){
                                        g[j].erase(g[j].begin()+k);
                                    }
                                }
                                for (ll k = 0;k < sz(g[x]);k++){
                                    if (g[x][k]==j){
                                        g[x].erase(g[x].begin()+k);
                                    }
                                }
                                ok = 1;
                                break;
                            }
                        }
                    }
                }
                assert(ok);
            }
        }
//        memset(cnt,0,sizeof cnt);
//        for (ll i = 1;i <= n;i ++){
//            if (sz(g[i])<6)cnt[sz(g[i])]^=1;
//        }
//        assert(cnt[0]+cnt[1]+cnt[2]+cnt[3]+cnt[4]==0);
        cout<<sz(del)<<'\n';
        for (auto x:del)cout<<x.fi<<' '<<x.se<<'\n';
    }
    else{
        cout<<"ok";
    }
//    cout<<even<<'\n';
}


详细

Test #1:

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

input:

1000 3560
603 151
415 20
102 569
895 552
678 734
24 614
689 518
440 223
751 919
223 433
711 551
502 634
706 583
812 501
514 535
780 751
720 530
532 384
888 139
864 791
292 675
171 881
30 592
464 557
280 299
654 650
894 335
250 532
792 10
83 969
118 771
579 300
852 983
243 940
957 939
817 889
911 319...

output:

mark
4
501 812
32 575
1 488
10 521

input:

1000 3556
554 389
217 396
696 72
109 854
186 465
411 754
137 648
739 766
490 715
383 553
83 725
812 747
630 930
167 605
283 817
75 576
567 266
133 287
450 697
253 49
756 363
917 964
805 828
509 83
375 681
282 477
102 118
437 827
125 553
719 932
473 634
643 626
174 167
31 163
547 791
370 620
360 898
...

output:

ok

result:

ok all right

Test #2:

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

input:

1000 2000
457 335
160 497
464 992
892 255
853 3
308 301
970 363
541 299
89 418
425 128
626 827
603 854
484 874
755 295
607 483
798 552
356 850
320 357
254 940
675 901
168 525
301 636
520 555
773 910
343 701
889 966
218 529
909 950
71 64
682 284
424 138
721 792
670 544
386 72
654 909
725 235
592 437
...

output:

mark
2
8 747
238 902

input:

1000 1998
610 181
320 640
165 118
313 377
621 518
358 293
365 677
317 276
553 562
489 541
541 273
406 428
670 489
127 722
130 848
378 232
220 333
547 537
549 168
982 610
842 663
667 183
614 318
393 833
396 341
70 498
553 276
532 563
2 386
741 982
685 678
586 656
165 960
770 383
489 385
724 896
965 2...

output:

ok

result:

ok all right

Test #3:

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

input:

1000 5000
449 632
597 26
701 322
249 190
411 770
666 596
989 995
112 861
445 818
544 659
24 680
739 593
344 439
193 932
600 526
574 869
216 918
716 793
259 686
555 993
255 578
659 271
328 524
729 672
39 771
241 866
27 790
417 109
56 403
338 299
387 232
280 306
589 794
833 419
900 802
54 697
539 807
...

output:

mark
4
8 141
47 564
7 30
15 408

input:

1000 4996
833 551
737 671
283 611
208 474
311 340
317 170
361 855
56 586
530 544
764 500
689 741
106 702
61 748
374 442
387 349
916 647
945 982
202 160
684 604
287 812
835 285
749 449
380 162
116 561
612 251
215 30
386 476
739 706
603 499
761 533
302 419
543 454
247 228
560 870
89 246
256 352
530 72...

output:

ok

result:

ok all right

Test #4:

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

input:

1000 3156
347 398
792 278
754 442
413 757
391 130
636 625
207 437
81 415
47 974
887 779
524 619
379 894
868 594
653 919
29 117
123 867
632 505
648 147
130 420
495 876
637 659
882 348
462 878
282 646
398 525
419 224
926 448
305 934
855 570
396 345
774 918
336 123
502 491
984 783
845 142
790 594
754 4...

output:

mark
4
52 609
7 585
9 675
19 468

input:

1000 3152
496 759
406 439
654 583
845 121
909 56
213 734
883 467
159 221
128 944
114 341
59 604
346 326
300 494
150 447
660 986
101 811
455 976
738 816
843 648
608 674
761 910
309 418
980 885
544 355
474 786
392 886
28 441
766 778
856 876
533 668
636 974
879 34
423 841
710 958
8 548
884 857
611 741
...

output:

ok

result:

ok all right

Test #5:

score: 0
Wrong Answer on the first run

input:

1000 3433
634 21
789 966
541 959
213 381
366 781
107 649
747 122
336 869
222 648
833 972
929 524
712 524
744 525
568 679
634 163
901 501
56 518
128 587
720 117
208 439
860 85
852 168
934 947
34 858
520 568
408 464
232 432
999 504
71 982
957 372
570 436
281 309
410 405
521 275
554 589
4 707
498 148
5...

output:

mark
6
1 373
147 849
45 105
3 882
15 650
10 371

input:


output:


result:

wrong answer Integer parameter [name=k] equals to 6, violates the range [0, 5]