QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#322586 | #4829. Mark on a Graph | Pentagonal | 0 | 1925ms | 4356kb | C++17 | 6.6kb | 2024-02-07 11:46:45 | 2024-02-07 11:46:46 |
Judging History
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>
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];
int rng = 123;
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 = (73 * rrr + j + (rrr << 5)) % 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) {
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);
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 693ms
memory: 4260kb
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 17 176
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 757 70 962 736 11 36 37 355 600 53 201 783 267 511 790 201 951 583 937 221 8...
output:
ok
result:
ok all right
Test #2:
score: 100
Accepted
time: 131ms
memory: 3908kb
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 6 94
input:
1000 2001 181 610 640 320 451 386 377 313 97 233 231 106 993 482 403 152 835 246 554 952 541 72 227 182 962 916 584 649 546 673 962 651 108 699 731 324 39 263 541 268 568 620 379 375 415 582 622 628 341 884 672 70 564 349 532 563 99 37 741 982 23 450 411 738 758 235 770 529 312 78 838 977 956 965 50...
output:
ok
result:
ok all right
Test #3:
score: 100
Accepted
time: 1209ms
memory: 4164kb
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 21 175
input:
1000 5001 551 533 786 996 219 796 171 208 412 802 127 305 361 305 592 435 378 24 75 559 578 166 45 106 156 570 128 805 254 918 647 729 396 945 345 309 992 501 13 247 854 986 582 363 471 245 754 461 326 865 934 1 926 923 206 888 458 321 744 533 21 787 854 115 566 344 337 781 274 421 55 266 649 530 15...
output:
ok
result:
ok all right
Test #4:
score: 100
Accepted
time: 290ms
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 8 365
input:
1000 3157 540 43 167 499 403 962 814 342 154 900 376 966 366 612 456 962 777 715 539 243 157 28 582 563 810 843 38 856 841 423 811 101 952 757 435 668 64 778 925 392 396 865 503 527 481 64 311 954 315 976 508 855 940 42 161 215 501 285 617 957 869 225 879 34 610 421 127 448 58 923 748 615 671 799 71...
output:
ok
result:
ok all right
Test #5:
score: 100
Accepted
time: 1925ms
memory: 4056kb
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 48 322
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: 221ms
memory: 4240kb
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 6 934
input:
1000 3058 843 48 203 126 262 63 954 309 294 93 506 107 14 469 598 921 906 684 733 571 432 324 921 841 512 957 686 482 520 921 243 22 817 640 623 947 712 927 982 225 701 146 263 942 509 228 987 626 603 573 636 154 414 771 26 348 652 580 551 116 832 454 75 314 250 947 993 310 995 567 719 792 191 934 3...
output:
ok
result:
ok all right
Test #7:
score: 100
Accepted
time: 245ms
memory: 4212kb
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 7 488
input:
1000 3086 192 821 248 956 417 787 95 734 953 941 570 533 479 888 321 716 174 625 613 554 795 160 570 398 86 617 76 6 518 617 743 937 728 94 896 52 778 568 474 293 977 247 701 533 219 773 31 124 108 860 640 186 907 397 436 930 581 22 197 710 831 963 831 369 843 44 911 718 200 347 595 330 268 65 53 33...
output:
ok
result:
ok all right
Test #8:
score: 100
Accepted
time: 231ms
memory: 4136kb
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:
mark 1 5 434
input:
1000 4290 792 673 929 54 935 953 570 751 191 586 798 495 123 259 565 163 75 999 610 299 518 338 495 999 636 660 410 254 637 766 366 483 832 382 680 554 421 583 792 621 318 320 668 204 433 740 662 365 240 71 628 722 278 215 62 755 404 799 102 406 67 586 93 33 681 306 659 759 93 257 425 670 810 759 98...
output:
ok
result:
ok all right
Test #9:
score: 100
Accepted
time: 647ms
memory: 4336kb
input:
1000 4763 544 167 316 76 78 841 699 1 645 745 827 262 568 545 595 81 924 561 108 253 397 626 142 967 613 397 723 633 711 259 363 249 5 436 165 88 178 463 734 529 195 324 135 41 1000 136 215 967 371 638 588 753 542 909 633 106 537 852 111 232 303 500 892 461 868 300 772 667 40 172 956 575 613 163 933...
output:
mark 1 12 754
input:
1000 4764 450 710 910 637 220 393 624 951 228 948 299 625 271 750 329 347 156 263 710 337 416 936 591 237 22 837 367 754 516 762 500 30 444 557 857 161 82 705 824 969 586 313 800 90 224 370 971 78 767 435 558 429 66 526 667 703 847 158 148 37 968 872 965 793 396 746 15 388 778 116 820 306 862 678 53...
output:
ok
result:
ok all right
Test #10:
score: 100
Accepted
time: 714ms
memory: 4356kb
input:
1000 4250 747 446 769 425 773 753 217 298 217 4 514 774 752 3 905 857 532 410 224 250 367 33 29 541 809 996 76 960 25 603 532 600 518 304 546 95 735 413 312 476 83 534 157 62 170 836 668 976 244 557 972 860 828 170 975 468 677 714 800 170 530 191 216 930 242 728 318 505 269 162 579 963 769 822 171 4...
output:
mark 1 15 396
input:
1000 4251 112 370 102 703 776 233 835 409 598 303 590 999 320 874 639 193 378 512 447 83 308 365 152 512 219 36 14 309 600 242 8 847 585 656 524 394 600 888 342 188 275 604 326 920 728 164 380 74 892 31 797 986 984 629 148 404 377 353 270 344 578 582 5 848 261 174 398 338 494 140 371 94 146 199 45 2...
output:
ok
result:
ok all right
Test #11:
score: 100
Accepted
time: 65ms
memory: 4196kb
input:
1000 3336 161 745 81 702 879 347 452 553 809 32 359 925 984 783 558 366 611 89 948 530 565 496 123 348 534 986 991 511 322 407 6 878 20 897 188 150 527 440 487 333 218 572 597 575 308 684 50 780 900 451 763 785 210 682 964 992 811 537 537 167 320 133 523 899 629 732 435 281 826 405 868 567 201 858 2...
output:
mark 1 2 512
input:
1000 3337 1000 599 420 343 900 936 700 161 202 1000 338 992 72 621 164 413 432 826 419 154 394 958 412 217 675 438 58 687 433 172 991 599 877 884 373 329 90 134 957 76 984 685 499 533 153 420 59 986 293 418 808 502 289 367 381 82 812 370 916 843 932 30 524 236 723 854 766 709 356 376 85 153 410 921 ...
output:
ok
result:
ok all right
Test #12:
score: 100
Accepted
time: 1014ms
memory: 4248kb
input:
1000 3482 910 881 481 989 349 262 963 679 970 752 651 210 86 339 724 310 765 410 118 619 662 351 568 148 292 61 136 385 997 772 210 735 816 310 698 649 581 313 414 280 92 872 965 925 35 930 813 29 617 210 854 940 486 479 412 644 660 623 126 85 664 327 459 165 266 113 108 206 686 660 918 536 173 366 ...
output:
mark 1 25 377
input:
1000 3483 73 216 26 960 633 88 543 818 650 60 89 532 706 504 396 473 87 574 944 144 436 698 109 269 668 71 400 568 443 464 680 920 384 711 455 324 487 770 791 666 344 549 906 733 544 682 624 433 862 240 189 630 262 218 812 625 840 631 346 452 543 492 723 843 539 742 511 97 616 452 391 89 744 173 852...
output:
ok
result:
ok all right
Test #13:
score: 100
Accepted
time: 131ms
memory: 3932kb
input:
1000 2141 358 723 692 581 753 295 864 391 984 462 525 271 508 897 739 537 124 933 577 499 863 37 279 622 361 605 454 951 527 837 1 224 641 404 479 220 931 126 182 719 464 451 805 452 529 800 292 689 17 320 728 790 967 41 412 752 276 535 643 636 611 56 802 414 861 603 857 722 1000 584 435 118 266 392...
output:
mark 1 5 957
input:
1000 2142 577 305 435 67 431 58 542 821 998 372 408 746 802 886 116 960 211 898 604 983 745 399 986 692 831 943 92 121 561 588 414 271 27 418 594 139 407 480 625 453 98 796 425 188 65 129 720 824 49 673 804 670 126 76 945 907 131 938 999 30 491 432 788 708 597 526 515 710 855 730 338 550 357 308 305...
output:
ok
result:
ok all right
Test #14:
score: 100
Accepted
time: 150ms
memory: 3940kb
input:
1000 2950 244 361 694 442 547 577 545 866 488 207 888 997 263 45 850 200 30 927 195 510 274 582 467 158 664 667 880 573 522 986 736 375 206 326 999 940 875 609 151 161 602 673 664 200 827 579 12 190 300 249 95 502 951 317 669 243 350 841 692 572 619 302 955 999 480 891 109 779 198 893 105 442 214 14...
output:
mark 1 5 34
input:
1000 2951 585 350 530 350 266 289 671 238 489 256 883 116 310 156 939 353 663 816 637 187 222 773 204 294 666 180 995 89 256 492 570 257 109 563 939 293 964 992 66 754 878 60 793 916 710 944 43 981 609 3 914 367 578 462 262 59 806 755 239 845 180 476 763 865 131 248 833 279 15 841 209 418 426 11 760...
output:
ok
result:
ok all right
Test #15:
score: 100
Accepted
time: 864ms
memory: 3904kb
input:
1000 2725 336 461 575 6 961 482 496 574 134 336 671 452 172 957 633 89 909 334 222 155 90 660 201 950 436 671 726 683 487 356 536 389 107 844 403 732 550 608 607 54 718 438 960 144 710 278 398 747 152 501 86 385 34 251 309 822 773 321 329 213 897 948 356 401 290 329 278 591 683 454 122 523 729 436 4...
output:
mark 1 27 365
input:
1000 2726 826 863 860 669 482 188 461 442 496 849 962 420 832 558 899 680 933 304 876 932 6 579 49 750 506 996 166 759 563 508 331 228 210 471 707 306 89 391 16 349 161 923 496 830 591 108 534 553 220 382 489 624 969 790 385 891 900 848 69 837 478 216 455 579 539 29 37 915 554 860 316 683 143 324 33...
output:
ok
result:
ok all right
Test #16:
score: 100
Accepted
time: 1306ms
memory: 3956kb
input:
1000 2812 357 725 462 948 927 875 21 284 52 197 457 876 744 315 990 255 660 522 51 971 392 275 736 77 131 216 581 438 495 271 965 111 376 89 824 363 628 13 33 585 836 144 791 404 916 588 668 243 960 335 505 368 744 264 332 893 65 320 205 81 929 44 135 224 306 351 938 505 70 927 825 634 161 492 434 1...
output:
mark 1 39 755
input:
1000 2813 677 548 157 134 87 218 65 463 383 514 308 894 81 900 400 922 364 176 59 893 403 327 525 873 996 629 152 187 592 100 405 99 353 321 445 597 745 371 291 135 207 63 424 703 446 391 166 83 146 844 237 635 524 740 608 279 898 307 334 172 672 353 954 603 156 224 296 172 897 177 437 214 736 205 8...
output:
ok
result:
ok all right
Test #17:
score: 100
Accepted
time: 147ms
memory: 4208kb
input:
1000 2616 518 38 164 144 301 140 711 11 36 636 443 779 107 901 467 922 759 675 229 276 467 880 975 435 382 460 238 663 639 927 74 953 777 326 689 944 152 237 501 789 795 889 95 376 390 401 279 64 520 803 273 292 333 454 202 485 860 54 872 641 101 951 236 726 464 847 992 656 576 565 739 176 562 327 2...
output:
mark 1 5 565
input:
1000 2617 903 669 336 738 42 963 55 717 90 323 166 928 895 254 138 853 709 590 223 681 978 55 763 978 465 508 887 251 112 973 947 939 722 700 919 328 792 949 793 266 96 854 600 375 710 491 530 126 461 666 823 561 78 124 959 230 718 623 22 893 313 914 81 851 610 950 321 397 607 697 789 15 151 154 518...
output:
ok
result:
ok all right
Test #18:
score: 0
Stage 1: Program answer Time Limit Exceeded
input:
1000 4792 659 787 666 143 711 116 742 958 604 434 293 882 175 28 557 753 106 808 527 599 942 249 843 109 174 76 429 255 415 489 463 540 878 235 688 87 629 402 927 418 704 734 886 463 702 992 570 370 492 865 795 889 638 594 887 203 732 896 610 492 960 422 44 255 442 448 426 697 862 351 318 277 783 22...