QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#294907#4829. Mark on a Graphucup-team055#0 2ms3732kbC++231.8kb2023-12-30 17:19:402023-12-30 17:19:40

Judging History

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

  • [2023-12-30 17:19:40]
  • 评测
  • 测评结果:0
  • 用时:2ms
  • 内存:3732kb
  • [2023-12-30 17:19:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LLONG_MAX / 4;
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define all(a) begin(a), end(a)
template<class T> bool chmin(T& a, T b) { if(a <= b) return 0; a = b; return 1; }
template<class T> bool chmax(T& a, T b) { if(a >= b) return 0; a = b; return 1; }


mt19937 rnd(169);
int main() {
//    cin.tie(0)->sync_with_stdio(0);
    
    ll N, M;
    cin >> N >> M;
    
    vector g(N, vector<ll>{});
    rep(i, 0, M) {
        ll A, B;
        cin >> A >> B;
        A--; B--;
        g[A].push_back(B);
        g[B].push_back(A);
    }
    
    vector<ll> deg(N);
    rep(i, 0, N) deg[i] = g[i].size();
    
    vector<ll> hist(100);
    for(ll x : deg) hist[x]++;
    auto p = ranges::max_element(hist);
    
    while(*p > 10) p++;
    
    if(*p == 0) {
        puts("ok");
        return 0;
    }
    
    puts("mark");
    puts("5");
    
    vector<ll> idx;
    rep(i, 0, N) if(deg[i] >= p - begin(hist)) idx.push_back(i);
    ranges::sort(idx, less<>{}, [&](ll i) { return g[i].size(); });
    rep(i, 0, N) if(idx.size() < 10 and g[i].empty()) idx.push_back(i);
    idx.resize(10);
    
    auto has_edge = [&](ll i, ll j) -> bool {
        return ranges::count(g[i], j);
    };
    
    auto add_edge = [&](ll i, ll j) -> bool {
        if(i == j) return 0;
        if(ranges::count(g[i], j)) return 0;
        g[i].push_back(j);
        g[j].push_back(i);
        
        cout << i + 1 << ' ' << j + 1 << endl;
        return 1;
    };
    
    ranges::sort(idx);
    while([&] {
        rep(i, 0, 5) if(has_edge(idx[i * 2], idx[i * 2 + 1])) return 1;
        return 0;
    }()) ranges::shuffle(idx, rnd);
    
    rep(i, 0, 5) add_edge(idx[i * 2], idx[i * 2 + 1]);
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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
5
80 108
489 497
543 547
611 680
875 907

input:

1000 3565
626 311
882 830
665 298
779 269
682 582
107 833
155 683
656 183
184 255
392 381
676 187
63 633
397 161
770 790
222 180
402 763
439 897
224 873
974 302
521 734
368 520
794 262
113 578
66 583
715 526
457 125
567 806
188 419
464 840
11 36
355 335
232 412
14 201
368 394
201 178
992 583
221 937...

output:

ok

result:

ok all right

Test #2:

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

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
5
79 151
592 600
610 727
747 761
902 966

input:

1000 2005
610 181
320 640
386 451
377 313
97 233
106 231
482 993
440 112
246 835
141 940
431 764
220 6
395 217
728 734
769 570
651 962
699 108
731 324
378 39
299 660
683 752
634 379
415 582
21 500
999 501
70 498
564 435
532 563
37 99
457 132
450 955
411 388
235 758
569 595
312 78
164 364
633 94
50 5...

output:

ok

result:

ok all right

Test #3:

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

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
5
805 744
20 636
567 732
794 359
271 304

input:

1000 5005
551 153
334 992
476 219
208 346
802 385
305 127
150 361
435 592
24 378
341 805
699 578
106 119
963 570
128 182
917 352
647 41
128 752
345 596
992 354
13 247
309 188
890 582
471 334
754 461
326 618
127 830
923 926
138 888
321 569
744 533
207 306
5 115
344 235
781 688
421 274
129 462
530 634...

output:

ok

result:

ok all right

Test #4:

score: 100
Accepted
time: 2ms
memory: 3636kb

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
5
115 222
386 394
422 598
757 796
881 951

input:

1000 3161
540 769
330 167
856 918
342 519
753 154
376 292
612 359
712 549
577 777
606 691
157 28
468 773
111 685
856 150
841 721
101 811
7 717
668 290
481 64
925 798
529 865
417 503
853 843
669 687
697 339
106 45
403 566
295 871
861 501
617 957
18 225
879 34
329 421
127 255
923 765
125 517
527 671
5...

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
5
33 75
214 432
631 797

input:


output:


result:

wrong output format Unexpected end of file - int32 expected