QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#322584 | #4829. Mark on a Graph | Pentagonal | 0 | 1883ms | 4364kb | C++17 | 6.4kb | 2024-02-07 11:43:20 | 2024-02-07 11:43:21 |
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 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;
}
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) {
// hash1();
// if (j == 100) return 0;
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: 343ms
memory: 3996kb
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 1 805
input:
1000 3561 269 626 295 222 665 959 909 534 682 161 833 706 155 199 841 656 184 286 383 294 259 86 771 532 37 355 755 167 484 763 209 250 693 401 850 500 902 369 521 380 363 479 676 977 920 112 831 175 688 730 692 125 654 102 757 70 962 736 87 733 373 956 600 137 201 783 267 511 790 201 975 583 937 55...
output:
ok
result:
ok all right
Test #2:
score: 100
Accepted
time: 1265ms
memory: 3868kb
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: 118ms
memory: 4364kb
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 1 192
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: 1883ms
memory: 3964kb
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 5 910
input:
1000 3157 759 496 167 24 403 342 814 342 154 870 990 212 366 612 456 962 777 806 539 72 441 28 582 563 426 843 998 856 986 660 811 609 952 757 533 668 64 778 925 933 693 865 272 415 481 64 758 954 315 423 463 213 303 356 312 215 501 285 617 957 974 636 879 919 924 421 127 448 505 523 748 615 664 881...
output:
ok
result:
ok all right
Test #5:
score: 100
Accepted
time: 519ms
memory: 3992kb
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 2 259
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: 578ms
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 2 565
input:
1000 3058 29 48 203 126 942 210 954 309 294 719 506 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 228 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 792 191 934 578 2...
output:
ok
result:
ok all right
Test #7:
score: 100
Accepted
time: 176ms
memory: 3916kb
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 1 468
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 389 458 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: 265ms
memory: 4280kb
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 1 510
input:
1000 4290 792 673 929 54 935 953 570 751 368 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 74 443 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 982...
output:
ok
result:
ok all right
Test #9:
score: 100
Accepted
time: 319ms
memory: 4300kb
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 1 547
input:
1000 4764 450 710 910 637 103 839 624 791 228 948 299 625 271 750 329 347 156 263 710 838 914 936 591 421 22 837 990 918 516 762 500 181 444 557 857 161 635 705 821 379 332 116 800 90 224 370 971 78 767 435 558 429 66 526 667 394 847 158 148 37 968 872 965 793 396 746 331 388 180 214 820 306 862 678...
output:
ok
result:
ok all right
Test #10:
score: 100
Accepted
time: 1031ms
memory: 4064kb
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 3 44
input:
1000 4251 112 370 102 703 776 233 835 409 598 303 9 55 320 874 639 193 819 701 447 83 308 365 300 156 219 36 14 309 617 487 685 229 585 656 79 394 495 250 342 188 275 604 326 920 728 164 380 74 892 31 797 986 984 629 148 404 377 353 270 60 578 582 5 848 261 174 398 338 494 140 371 94 146 199 45 240 ...
output:
ok
result:
ok all right
Test #11:
score: 100
Accepted
time: 393ms
memory: 4200kb
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 1 982
input:
1000 3337 252 599 857 343 900 936 548 161 202 1000 338 992 974 621 164 413 141 280 319 655 137 958 412 217 70 438 58 687 433 172 423 120 877 884 373 638 90 134 957 285 984 281 318 962 153 420 992 986 627 418 964 502 864 80 695 726 812 370 916 843 932 30 408 236 480 741 88 712 83 310 85 93 809 921 50...
output:
ok
result:
ok all right
Test #12:
score: 100
Accepted
time: 345ms
memory: 4172kb
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 1 836
input:
1000 3483 732 216 26 960 633 812 543 818 650 60 104 532 597 504 46 473 87 574 944 144 436 698 109 269 668 71 400 568 739 307 680 811 384 711 455 148 487 770 791 666 52 549 160 733 544 682 624 866 862 240 674 630 256 803 812 625 840 631 346 963 543 492 767 843 539 742 594 935 616 825 391 131 744 173 ...
output:
ok
result:
ok all right
Test #13:
score: 100
Accepted
time: 569ms
memory: 3800kb
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 3 154
input:
1000 2142 482 327 271 721 842 324 542 340 998 774 33 221 560 886 635 960 439 180 925 983 745 305 306 334 376 422 816 821 561 366 414 613 27 223 594 270 849 152 625 453 98 796 425 37 257 760 376 824 49 680 225 670 988 76 945 907 131 310 999 30 491 432 788 961 597 489 34 710 587 409 623 686 967 308 90...
output:
ok
result:
ok all right
Test #14:
score: 100
Accepted
time: 1431ms
memory: 3964kb
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: 356ms
memory: 3912kb
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 2 80
input:
1000 2726 826 863 593 547 482 188 461 442 496 849 962 420 832 558 899 680 933 304 876 932 6 579 71 716 506 996 166 759 563 508 331 228 210 471 707 306 89 259 16 349 161 923 496 830 591 108 534 553 220 382 489 624 969 790 385 53 900 848 69 837 478 216 455 579 286 174 37 915 554 860 316 683 143 324 33...
output:
ok
result:
ok all right
Test #16:
score: 100
Accepted
time: 123ms
memory: 4156kb
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 1 358
input:
1000 2813 677 559 157 134 87 218 65 463 930 242 308 94 994 900 400 922 977 176 59 893 403 802 957 882 143 629 152 187 592 100 405 99 353 186 445 514 286 171 291 135 207 153 424 703 80 391 268 83 146 844 237 635 524 740 608 279 898 307 394 312 961 353 954 603 156 224 296 172 897 177 766 214 736 205 8...
output:
ok
result:
ok all right
Test #17:
score: 100
Accepted
time: 445ms
memory: 4064kb
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 2 396
input:
1000 2617 903 669 336 738 42 963 55 717 90 323 166 928 895 254 138 374 709 590 223 681 978 55 894 513 465 508 887 242 112 973 947 939 722 700 919 328 792 949 432 384 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...