QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#294177 | #4829. Mark on a Graph | ucup-team896# | 0 | 4ms | 4068kb | C++14 | 2.0kb | 2023-12-30 09:17:11 | 2023-12-30 09:17:13 |
answer
#include <bits/stdc++.h>
#ifdef dbg
#define D(...) fprintf(stderr, __VA_ARGS__)
#define DD(...) D("[Debug] "#__VA_ARGS__ " = "), \
debug_helper::debug(__VA_ARGS__), D("\n")
#include "C:\Users\wsyear\Desktop\OI\templates\debug.hpp"
#else
#define D(...) ((void)0)
#define DD(...) ((void)0)
#endif
#define rep(i, j, k) for (int i = (j); i <= (k); ++i)
#define per(i, j, k) for (int i = (j); i >= (k); --i)
#define SZ(v) int((v).size())
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
using ll = long long;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
template<class T> void chkmn(T &x, T y) { if (y < x) x = y; }
template<class T> void chkmx(T &x, T y) { if (y > x) x = y; }
using namespace std;
const int maxn = 1010;
int n, m, deg[maxn];
bitset<maxn> e[maxn];
vector<int> ed[maxn];
int main() {
cin.tie(nullptr) -> ios::sync_with_stdio(false);
cin >> n >> m;
rep (i, 1, m) {
int u, v;
cin >> u >> v;
deg[u]++, deg[v]++;
e[u].set(v), e[v].set(u);
ed[u].emplace_back(v);
ed[v].emplace_back(u);
}
int qwq = 0;
rep (i, 1, n) if (!deg[i]) qwq++;
int cnt = 0;
vector<int> d2;
rep (i, 1, n) if (deg[i] == 2) d2.emplace_back(i);
for (int a : d2) for (int b : d2) for (int c : d2) {
if (a == b || a == c || b == c) continue;
if (e[a].test(b) && e[b].test(c) && e[c].test(a)) cnt++;
}
if (cnt) return cout << "ok\n", 0;
cout << "mark\n";
vector<int> p(0);
rep (i, 1, n) p.emplace_back(i);
sort(ALL(p), [&](int x, int y) { return deg[x] < deg[y]; });
int a = p[0], b = p[1], c = p[2];
map<pii, int> mp;
for (int w : ed[a]) mp[minmax(w, a)] ^= 1;
for (int w : ed[b]) mp[minmax(w, b)] ^= 1;
for (int w : ed[c]) mp[minmax(w, c)] ^= 1;
mp[minmax(a, b)] ^= 1, mp[minmax(b, c)] ^= 1;
mp[minmax(c, a)] ^= 1;
vector<pii> ans(0);
for (auto [x, y] : mp) if (y) ans.emplace_back(x);
cout << SZ(ans) << '\n';
for (auto [x, y] : ans) cout << x << " " << y << '\n';
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4068kb
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 762 817 762 862 762 880 826 862 862 880
input:
1000 3561 107 626 295 222 601 563 909 534 682 257 833 706 155 524 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 93 692 125 654 102 757 70 962 736 87 733 373 956 600 137 201 783 267 511 790 201 975 583 937 557...
output:
ok
result:
ok all right
Test #2:
score: 100
Accepted
time: 4ms
memory: 3824kb
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 3 345 493 345 508 493 508
input:
1000 2003 711 181 426 320 9 304 250 196 97 233 231 792 894 202 437 440 532 381 940 784 660 299 73 6 690 916 640 649 197 570 189 823 178 529 731 827 632 952 519 541 683 752 379 835 582 415 628 115 257 999 70 274 564 360 863 90 592 534 132 457 450 955 411 279 758 705 167 507 78 414 605 104 965 231 405...
output:
ok
result:
ok all right
Test #3:
score: 0
Wrong Answer on the first run
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 9 2 231 35 98 98 231 98 673 98 786 231 527 231 673 673 755 673 882
input:
output:
result:
wrong answer Integer parameter [name=k] equals to 9, violates the range [0, 5]