QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#791651#898. 二分图最大匹配Mr_MinWA 90ms15584kbC++14888b2024-11-28 20:05:042024-11-28 20:05:09

Judging History

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

  • [2024-11-28 20:05:09]
  • 评测
  • 测评结果:WA
  • 用时:90ms
  • 内存:15584kb
  • [2024-11-28 20:05:04]
  • 提交

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;
  vector < int > ord(l);
  iota(ord.begin(), ord.end(), 0);
  mt19937 rng(random_device{}());
  shuffle(ord.begin(), ord.end(), rng);
  for (int i : ord) ret += dfs(i, i);
  cout << ret << '\n';
  for (int i = 0; i < l; i++) {
    if (~mch[i]) cout << mch[i] << ' ' << i << '\n';
  }
  return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 80ms
memory: 13704kb

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

result:

ok OK

Test #2:

score: 0
Accepted
time: 72ms
memory: 15584kb

input:

100000 100000 200000
56815 52516
2576 76201
40377 1757
50463 66496
15833 50879
9828 16330
80692 9962
51095 17590
15870 35191
91301 65509
90774 57492
11890 8966
44786 41895
3386 35478
93470 47452
84803 93635
90745 34876
18201 38717
7472 34257
36580 19532
13248 27524
6441 69869
8821 61870
94536 67713
...

output:

100000
97875 0
94264 1
74429 2
66378 3
74096 4
51747 5
18521 6
42713 7
40688 8
99131 9
51895 10
33489 11
99689 12
77565 13
47931 14
25562 15
25766 16
55887 17
2119 18
45605 19
11619 20
51396 21
81044 22
91839 23
83277 24
87787 25
9579 26
95681 27
76389 28
75933 29
50341 30
81760 31
65030 32
2286 33
...

result:

ok OK

Test #3:

score: 0
Accepted
time: 1ms
memory: 6904kb

input:

4 4 7
1 1
2 2
0 0
3 1
1 2
2 0
3 2

output:

3
0 0
1 1
3 2

result:

ok OK

Test #4:

score: 0
Accepted
time: 66ms
memory: 14424kb

input:

100000 100000 199999
25370 25370
85964 85963
415 415
16796 16796
12437 12437
45409 45408
63005 63004
22155 22155
87828 87827
84013 84013
37307 37307
72324 72324
83703 83703
55390 55389
6780 6779
78090 78090
9375 9375
82192 82192
74694 74694
49841 49841
15798 15798
69855 69854
82948 82947
97389 97388...

output:

100000
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20
21 21
22 22
23 23
24 24
25 25
26 26
27 27
28 28
29 29
30 30
31 31
32 32
33 33
34 34
35 35
36 36
37 37
38 38
39 39
40 40
41 41
42 42
43 43
44 44
45 45
46 46
47 47
48 48
49 49
50 50
51 51
5...

result:

ok OK

Test #5:

score: 0
Accepted
time: 59ms
memory: 12280kb

input:

100000 100000 199999
59469 59469
76773 76772
89516 89516
87040 87040
90184 90184
83075 83075
61454 61454
33615 33615
85794 85793
92072 92071
49725 49725
63842 63841
99247 99247
24121 24121
29552 29551
73533 73533
75845 75845
27029 27028
84418 84418
26636 26636
10100 10099
75013 75012
67341 67341
756...

output:

100000
0 0
1 1
2 2
3 3
4 4
5 5
6 6
7 7
8 8
9 9
10 10
11 11
12 12
13 13
14 14
15 15
16 16
17 17
18 18
19 19
20 20
21 21
22 22
23 23
24 24
25 25
26 26
27 27
28 28
29 29
30 30
31 31
32 32
33 33
34 34
35 35
36 36
37 37
38 38
39 39
40 40
41 41
42 42
43 43
44 44
45 45
46 46
47 47
48 48
49 49
50 50
51 51
5...

result:

ok OK

Test #6:

score: 0
Accepted
time: 90ms
memory: 14536kb

input:

100000 100000 199999
22284 45795
32144 44930
58734 13903
57136 34144
7548 92850
56318 11874
77529 85278
27039 51542
77506 94257
69265 89381
67073 61392
86159 96135
83227 74827
14857 19500
32084 73639
86884 174
27268 94390
20020 55019
45357 92587
17833 7902
55801 46032
36293 46557
73555 13746
8418 88...

output:

100000
63893 0
88633 1
96752 2
85610 3
94676 4
76685 5
31448 6
72044 7
70240 8
47175 9
43951 10
20110 11
30466 12
4229 13
46522 14
75223 15
62176 16
26851 17
78013 18
4961 19
85970 20
83385 21
99925 22
9079 23
99774 24
49446 25
97056 26
50528 27
24373 28
33211 29
47321 30
59580 31
78298 32
4755 33
9...

result:

ok OK

Test #7:

score: 0
Accepted
time: 69ms
memory: 12928kb

input:

100000 100000 199999
4850 52516
2576 29250
69016 1757
85854 66496
48300 50879
83741 16330
98931 9962
38730 17590
15870 13960
91301 97595
81692 57492
11890 59332
5076 41895
23574 35478
93470 65245
61976 93635
96140 34876
18201 35366
64057 34257
25588 19532
13248 91003
6441 83448
99191 61870
94536 169...

output:

100000
69205 0
60201 1
72021 2
5586 3
28931 4
95944 5
6919 6
54536 7
41523 8
21986 9
82162 10
3261 11
32139 12
82628 13
19581 14
53638 15
86118 16
55752 17
51052 18
29539 19
19938 20
88017 21
72427 22
50563 23
84262 24
96952 25
68293 26
77883 27
15925 28
17312 29
15316 30
64234 31
34238 32
21423 33
...

result:

ok OK

Test #8:

score: -100
Wrong Answer
time: 38ms
memory: 9044kb

input:

61217 61379 199943
14003 13749
24504 24347
30371 30219
27661 27461
33247 33397
38346 38157
17300 16944
50476 50643
56488 56551
46690 46949
21355 21288
3899 3659
24330 24165
8806 8305
40957 40994
15089 14813
20397 20389
30864 30800
33635 33755
20900 20808
55447 55499
4335 4040
36726 36551
16496 16095...

output:

37154
1 0
21 1
14 2
17 3
15 4
16 5
18 7
19 9
13 10
11 11
20 12
12 13
23 14
24 15
30 20
34 22
31 28
32 29
35 31
33 35
46 38
39 39
44 40
41 44
45 45
36 46
60 51
52 52
53 53
50 54
54 55
66 57
70 61
71 63
64 65
85 67
86 69
83 71
80 72
79 73
84 74
90 75
89 76
87 77
88 78
104 79
96 80
107 85
119 95
112 96...

result:

wrong output format Unexpected end of file - int32 expected