QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#791634#898. 二分图最大匹配Mr_MinWA 85ms15816kbC++14760b2024-11-28 19:59:542024-11-28 20:00:02

Judging History

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

  • [2024-11-28 20:00:02]
  • 评测
  • 测评结果:WA
  • 用时:85ms
  • 内存:15816kb
  • [2024-11-28 19:59:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
constexpr int N = 1e5 + 5;
vector < int > g[N];
int l, r, m, mch[N], vis[N];
int dfs(int u, int t) {
  if (vis[u] == t) return 0;
  vis[u] = t;
  for (int v : g[u]) {
    if (!~mch[v] || dfs(mch[v], t)) return mch[v] = u, 1;
  }
  return 0;
}

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  cin >> l >> r >> m;
  memset(mch, -1, sizeof(mch));
  memset(vis, -1, sizeof(vis));
  for (int i = 1, u, v; i <= m; i++) {
    cin >> u >> v;
    g[u].push_back(v);
  }
  int ret = 0;
  for (int i = 0; i < l; i++) ret += dfs(i, i);
  cout << ret << '\n';
  for (int i = 0; i < l; i++) {
    if (~mch[i]) cout << i << ' ' << mch[i] << '\n';
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 85ms
memory: 15816kb

input:

100000 100000 200000
78474 45795
32144 46392
92549 13903
73460 34144
96460 92850
56318 77066
77529 84436
76342 51542
77506 99268
76410 89381
1778 61392
43607 96135
84268 74827
14857 35966
32084 94908
19876 174
1481 94390
12423 55019
64368 92587
81295 7902
25432 46032
36293 61128
73555 84836
8418 102...

output:

100000
0 12041
1 72487
2 5283
3 69829
4 42164
5 90712
6 92014
7 59953
8 71269
9 58488
10 96208
11 72327
12 57264
13 60846
14 52381
15 59008
16 50389
17 35924
18 32625
19 21527
20 27578
21 47990
22 90601
23 76846
24 36019
25 21960
26 56983
27 38043
28 92270
29 25033
30 16929
31 23472
32 49575
33 7705...

result:

wrong answer Matching is incorrect (0, 12041)