QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#479866#898. 二分图最大匹配Kalenist#TL 94ms14184kbC++14665b2024-07-15 21:21:582024-07-15 21:21:59

Judging History

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

  • [2024-07-15 21:21:59]
  • 评测
  • 测评结果:TL
  • 用时:94ms
  • 内存:14184kb
  • [2024-07-15 21:21:58]
  • 提交

answer

#include<bits/stdc++.h>
#define N 100010
#define For(i,a,b) for(register int i=a;i<=b;i++)
using namespace std;
int L,R,m,vis[N],ml[N],mr[N],ans;
vector<int> go[N];
inline bool dfs(int x,int t)
{
    if(vis[x] == t) return false;
    vis[x]=t;
    for(int to:go[x])
        if(!mr[to] || dfs(mr[to],t))
            {ml[x]=to,mr[to]=x;return true;}
    return false;
}

int main()
{
    ios::sync_with_stdio(false);
    cin>>L>>R>>m;
    For(i,1,m) 
    {
        int x,y;cin>>x>>y;
        go[x+1].push_back(y+1);
    }For(i,1,L) ans+=dfs(i,i);
    cout<<ans<<'\n';
    For(i,1,L) if(ml[i]) cout<<i-1<<' '<<ml[i]-1<<'\n';
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 94ms
memory: 14184kb

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 54731
1 26066
2 89637
3 1717
4 68505
5 28330
6 55261
7 34703
8 42170
9 23249
10 90437
11 69580
12 72086
13 47593
14 29944
15 87183
16 763
17 2814
18 46044
19 75228
20 11487
21 72701
22 60611
23 36775
24 66081
25 45592
26 3321
27 88211
28 71467
29 47516
30 55528
31 83162
32 46298
33 26459
34...

result:

ok OK

Test #2:

score: 0
Accepted
time: 91ms
memory: 11824kb

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
0 49451
1 29914
2 31512
3 87445
4 91463
5 83824
6 17634
7 33390
8 66264
9 12388
10 9428
11 77732
12 80853
13 15512
14 39374
15 63409
16 17216
17 7319
18 83326
19 39754
20 25212
21 6189
22 61240
23 26716
24 73214
25 18227
26 17935
27 44486
28 6804
29 36155
30 36983
31 34087
32 39785
33 73657
3...

result:

ok OK

Test #3:

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

input:

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

output:

3
0 0
1 1
2 2

result:

ok OK

Test #4:

score: -100
Time Limit Exceeded

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:


result: