QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#294179#4829. Mark on a Graphucup-team896#0 1ms3980kbC++142.0kb2023-12-30 09:21:472023-12-30 09:21:48

Judging History

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

  • [2023-12-30 09:21:48]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3980kb
  • [2023-12-30 09:21:47]
  • 提交

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, d1;
  rep (i, 1, n) if (deg[i] == 1) d1.emplace_back(i);
  rep (i, 1, n) if (deg[i] == 2) d2.emplace_back(i);
  for (int a : d1) for (int b : d2) for (int c : d1) {
    if (a == b || a == c || b == c) continue;
    if (e[a].test(b) && e[b].test(c)) 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;
  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: 3980kb

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
4
762 817
762 862
762 880
826 862

input:

1000 3560
554 950
217 396
376 466
702 854
18 186
833 50
137 648
739 710
184 95
383 358
175 831
48 355
279 349
167 174
494 970
582 250
506 567
695 500
326 595
253 49
418 368
882 964
292 403
831 643
999 851
125 553
102 506
437 827
726 125
932 719
641 339
948 721
790 770
146 267
749 719
186 465
360 898...

output:

ok

result:

ok all right

Test #2:

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

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
2
345 508
493 508

input:

1000 2002
610 181
640 320
118 338
250 196
621 518
358 213
525 365
912 594
562 553
541 519
660 299
134 848
385 489
758 650
72 848
332 232
333 220
36 877
522 665
167 679
842 663
236 995
781 614
193 126
257 999
906 319
276 553
532 563
3 629
132 457
685 572
411 279
165 960
167 507
489 295
605 104
965 23...

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
8
2 231
35 98
98 231
98 673
98 786
231 527
673 755
673 882

input:


output:


result:

wrong answer Integer parameter [name=k] equals to 8, violates the range [0, 5]