QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#322594#4829. Mark on a GraphPentagonal0 1942ms4216kbC++176.7kb2024-02-07 11:54:132024-02-07 11:54:13

Judging History

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

  • [2024-02-07 11:54:13]
  • 评测
  • 测评结果:0
  • 用时:1942ms
  • 内存:4216kb
  • [2024-02-07 11:54:13]
  • 提交

answer

// #pragma GCC target("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimization ("Ofast")
//#pragma GCC -Wnarrowing

//Template {
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>
using namespace std;
using namespace __gnu_pbds;
 
//IO templates
//Note: use endl only for interactive problems or to debug segfaults; use newl for other problems
#define newl "\n"
#define fastIO ios::sync_with_stdio(false); cin.tie(nullptr)
#define fileIO(x) ifstream fin((str) x + (str) ".in"); ofstream fout((str) x + (str) ".out");
// void fileIO(string x) {}
#define flush() fflush(stdout)
#define interact(n) fflush(stdout); cin >> n; if (n == -1) return 0
#define testcases int tt; cin >> tt; fun (i, tt) solve();

#define edgeIO(m) fun (i, m) {int a, b; cin >> a >> b; addEdges(a, b);}
#define WeightedEdgeIO(m) fun (i, m) {int a, b, c; cin >> a >> b >> c; addWeightedEdges(a, b, c);}
#define numberedEdgeIO(m) fun (i, m) {int a, b; cin >> a >> b; addWeightedEdges(a, b, i);}
//types
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ordered_multiset tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define ll long long
#define int long long
#define ld long double
#define str string
#define boolean bool
#define String string
 
//vector
#define pb push_back
#define append push_back
 
//pairs
#define mp make_pair
#define p2 pair<int, int>
#define p3 pair<int, p2>
#define m3(x, y, z) mp(x, mp(y, z))
#define ich first
#define ni second.first
#define sanshi second.second
 
//For loops
#define ahegao(i, a, b) for (int i = a; i < b; i++)
#define baka(i, b, a) for (int i = b; i > a; i--)
#define fun(i, n) for (int i = 1; i <= (n); (i)++)
#define fon(i, n) for (int i = 0; i < (n); (i)++)
#define fur(i, n) for (auto i : (n))
#define oniichan(i, n) for (auto &i : (n))
 
//Sorts
#define sz(aaa) ((signed) aaa.size())
// #define len(aaa) ((signed) aaa.size())
#define all(a) a.begin(), a.end()
#define Sort(a) sort((a).begin(), (a).end())
#define rSort(a) sort((a).rbegin(), (a).rend())
#define clamp(x, y) (x) = min((int) (x), (int) (y))
#define CLAMP(x, y) (x) = max((int) (x), (int) (y))
 
//Other stuff
#define pqueue priority_queue
#define elif else if
#define addEdges(a, b) adj[a].pb(b); adj[b].pb(a)
#define addWeightedEdges(a, b, c) adj[a].pb(mp(b, c)); adj[b].pb(mp(a, c))
// #define find find_by_order
#define printLength(x) if (x < INF) cout << x << newl; else cout << -1 << newl;
// #define printVector(a) fur (i, a) cout << i << ' '; cout << newl;
void printVector(vector<int> DontUseThisName) {
    fur (i, DontUseThisName) cout << i << ' '; cout << newl;
}
void printVector(vector<p2> DontUseThisName) {
    fur (i, DontUseThisName) cout << i.first << ' ' << i.second << newl; cout << newl;
}
void printVector(vector<vector<int>> DontUseThisName) {
    fur (i, DontUseThisName) printVector(i); cout << newl;
}
ll max(ll a, signed b) {return max(a, (ll) b);}
ll max(signed a, ll b) {return max((ll) a, b);}

void pv(int a) {cout << a << newl;}
void pv(int a, int b) {printVector({a, b});}
void pv(p2 a) {printVector({a.first, a.second});};
void pv(int a, int b, int c) {printVector({a, b, c});}
void pv(int a, int b, int c, int d) {printVector({a, b, c, d});}
void pv(int a, int b, int c, int d, int e) {printVector({a, b, c, d, e});}
void pv(int a, int b, int c, int d, int e, int f) {printVector({a, b, c, d, e, f});}
// void pv(int a, )
// void printVector(vector<char> DontUseThisName) {
//     fur (i, DontUseThisName) cout << i << ' '; cout << newl;
// }
// void printRange(vector<int>::iterator Left, vector<int>::iterator Right) {
//     for (auto i = Left; i < Right; i++) cout << *i << ' ';
//     cout << newl;
// } 
//Constants
// const int MOD =  1e9+7; // 998244353
// const int SMALLMOD = 998244353;
const int INF = 2e9+1337;
const ll EXCEED = 2e18+1337;
const ll GRAVITY = 8e18;

//#define vectorIO(n, MikuBondage) fun (j, n) {int i; cin >> i; MikuBondage.pb(i);}
void vectorIO(int n, vector<int> &DontUseThisName) {
    fun (j, n) {int i; cin >> i; DontUseThisName.pb(i);}
}
//#define vector2IO(n, MikuBondage) fun (j, n) {int i, ii; cin >> i >> ii; MikuBondage.pb(mp(i, ii));}
void vector2IO(int n, vector<p2> &DontUseThisName) {
    fun (j, n) {int i, ii; cin >> i >> ii; DontUseThisName.pb(mp(i, ii));}
}

// const int dx[4] = {1, -1, 0, 0}, dy[4] = {0, 0, 1, -1};
#define shortest_path_queue priority_queue<p2, vector<p2>, greater<p2>>
#define printArray(DontUseThisName, NakedLolisGalore, GenshinImpactClimbing) ahegao (j, NakedLolisGalore, GenshinImpactClimbing + 1) cout << DontUseThisName[j] << ' '; cout << newl;
#define print2dArray(SplitComplexProblemsIntoMultipleParts, ScuteSwarm, GenshinImpactClimbing) fun (i, ScuteSwarm) {fun (j, GenshinImpactClimbing) cout << SplitComplexProblemsIntoMultipleParts[i][j] << ' '; cout << newl;}
//}
const int MAX = 1003;
const int MOD = 2003;
int n, m, k, curr;
set<int> adj[MAX];
int cnt[1003];
unsigned long long rng = chrono::steady_clock::now().time_since_epoch().count();
int hash1() {
    vector<int> aaa;
    fun (i, n) {
        vector<int> temp;
        fur (j, adj[i]) temp.pb(sz(adj[j]));
        Sort(temp);
        int res = 1;
        fur (j, temp) res = (71 * res + 43 * j) % MOD;
        cnt[i] = res;
    }
    fun (i, n) {
        vector<int> temp;
        fur (j, adj[i]) temp.pb(cnt[j]);
        Sort(temp);
        int res = 1;
        fur (j, temp) res = (71 * res + j) % MOD;
        aaa.pb(res);
    }
    // Sort(aaa);
    int rrr = 1;
    fur (j, aaa) rrr = (rrr + j * j * j) % MOD;
    // pv(rrr);
    return rrr;
}

int randint() {
    rng = ((1337 * (rng % 483187) + (rng << 5) + (rng << 27) + 987654321 + (rng % 235612) * (rng * 55679))) % INF;
    return rng;
}

signed main() {
    fastIO;
    cin >> n >> m;
    // edgeIO(m);
    fun (i, m) {
        int a, b; cin >> a >> b;
        adj[a].insert(b); adj[b].insert(a);
    }
    // cout << hash1() << newl;
    if (hash1() == 1337) {
        cout << "ok";
        return 0;
    }
    // return 0;
    // fun (i, n) ahegao (j, i+1, n+1) {
    fun (i, n) ahegao (j, i+1, n+1) {
        if (randint() % 10) continue;
        if (adj[i].find(j) == adj[i].end()) {
            adj[i].insert(j);
            adj[j].insert(i);
            if (hash1() == 1337) {
                cout << "mark" << newl;
                cout << 1 << newl;
                pv(i, j);
                return 0;
            }
            adj[i].erase(j);
            adj[j].erase(i);
        }
       
    }
}

详细

Test #1:

score: 100
Accepted
time: 125ms
memory: 4004kb

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
1
4 121 

input:

1000 3561
269 626
882 830
665 959
338 534
682 161
833 50
155 199
183 656
184 95
383 358
259 450
771 817
335 355
174 167
402 763
582 250
950 401
850 500
902 369
521 246
368 418
794 262
920 351
831 643
688 730
553 125
506 102
419 188
962 736
11 36
37 355
600 53
201 783
267 511
790 201
951 583
937 221
...

output:

ok

result:

ok all right

Test #2:

score: 100
Accepted
time: 468ms
memory: 3896kb

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
1
24 731 

input:

1000 2001
181 711
426 320
503 386
377 826
97 233
231 792
993 1
403 152
381 532
554 952
541 72
227 182
962 916
584 649
252 673
756 751
529 178
731 827
39 689
541 268
568 620
379 375
727 755
622 628
341 884
672 70
564 74
863 90
99 543
25 834
23 450
411 738
758 705
770 529
414 78
838 977
956 965
50 924...

output:

ok

result:

ok all right

Test #3:

score: 100
Accepted
time: 1942ms
memory: 4180kb

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
1
37 817 

input:

1000 5001
551 533
786 996
219 796
171 208
740 802
127 428
361 305
479 435
121 24
75 559
578 166
45 106
23 570
128 805
917 352
647 492
396 945
345 309
992 501
13 996
854 465
582 363
471 103
780 461
326 859
516 1
839 62
206 888
458 321
181 533
21 787
854 115
566 344
337 781
274 629
55 266
634 530
157 ...

output:

ok

result:

ok all right

Test #4:

score: 100
Accepted
time: 762ms
memory: 4216kb

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
1
23 993 

input:

1000 3157
759 496
167 24
403 342
814 342
154 870
990 212
111 612
456 357
777 806
539 72
441 28
582 645
426 843
998 856
986 660
811 609
952 147
533 668
64 836
925 933
693 865
272 415
376 64
758 954
315 423
463 213
303 356
312 215
248 330
617 957
974 636
879 919
924 421
127 383
505 523
748 926
664 881...

output:

ok

result:

ok all right

Test #5:

score: 100
Accepted
time: 1567ms
memory: 4096kb

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
1
46 298 

input:

1000 3434
901 246
623 554
416 864
837 660
635 898
735 811
356 790
272 376
783 207
899 769
437 114
257 179
291 607
514 98
669 181
109 968
905 300
341 848
451 211
992 861
307 925
776 682
505 132
31 681
892 451
669 188
24 655
5 358
753 318
505 99
671 425
441 167
30 188
410 42
82 762
344 661
6 213
667 8...

output:

ok

result:

ok all right

Test #6:

score: 100
Accepted
time: 1038ms
memory: 4164kb

input:

1000 3057
985 223
432 967
405 822
845 650
893 646
599 718
754 710
333 73
392 355
895 496
200 562
816 36
457 953
9 623
889 662
482 590
249 29
689 694
185 990
285 690
12 323
611 560
903 722
476 86
105 666
441 193
695 640
36 617
840 42
80 527
977 539
606 150
384 585
784 648
919 360
157 532
568 98
995 8...

output:

mark
1
34 376 

input:

1000 3058
29 48
203 26
942 210
954 309
294 719
280 107
14 443
241 921
666 607
733 571
432 91
921 572
990 304
552 44
520 921
243 22
4 640
623 947
42 660
877 225
45 146
263 667
509 515
450 626
603 573
971 732
337 771
237 348
652 580
168 116
256 454
75 314
250 947
138 624
995 567
719 835
191 934
578 21...

output:

ok

result:

ok all right

Test #7:

score: 100
Accepted
time: 271ms
memory: 4076kb

input:

1000 3085
484 405
841 443
661 315
392 941
355 558
523 394
773 929
673 840
5 707
255 610
744 58
301 794
505 33
668 533
787 945
747 810
803 115
340 900
791 909
596 418
129 491
460 698
156 233
664 502
231 465
795 486
829 102
608 212
253 344
419 557
100 421
321 793
207 302
544 479
33 916
736 129
6 156
9...

output:

mark
1
9 780 

input:

1000 3086
665 821
248 628
417 787
95 734
953 941
570 533
479 888
883 619
174 625
613 554
480 160
570 398
86 617
76 6
518 662
743 672
728 94
896 52
778 568
474 293
977 247
701 533
219 773
31 664
108 860
640 186
907 603
436 948
289 874
197 710
831 963
453 369
843 44
765 772
200 347
595 330
959 65
53 3...

output:

ok

result:

ok all right

Test #8:

score: 0
Stage 1: Program answer Time Limit Exceeded

input:

1000 4289
963 66
959 467
930 83
419 699
731 948
702 583
699 245
636 721
859 551
377 251
90 889
286 843
908 47
864 979
223 948
269 684
85 579
162 376
414 255
602 884
65 132
842 907
488 360
553 898
649 249
253 711
675 632
629 446
708 413
819 511
512 113
189 76
242 464
828 261
440 737
643 389
75 907
49...

output:


input:


output:


result: