QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#790878 | #898. 二分图最大匹配 | _TLEer_# | TL | 92ms | 21608kb | C++14 | 787b | 2024-11-28 15:50:04 | 2024-11-28 15:50:05 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
int l,r,m,x,y,u[200010],v[200010],R;
vector<int> a[200010];
int cnt,pp[200010],vis[200010];
int dfs(int nw){
if(nw>100)
nw++,nw--;
for(auto it=a[nw].begin();it!=a[nw].end();){
int v=*it;/*it=a[nw].erase(it);*/it++;
if(vis[v]==R)continue;
vis[v]=R;
if(!pp[v]||dfs(pp[v])){
pp[v]=nw;pp[nw]=v;
return 1;
}
}
return 0;
}
signed main(){
ios::sync_with_stdio(false);
cin.tie();cout.tie();
cin>>l>>r>>m;
for(int i=1;i<=m;i++){
cin>>u[i]>>v[i];v[i]+=l;
u[i]++;v[i]++;
a[u[i]].emplace_back(v[i]);
// a[v[i]].emplace_back(u[i]);
}
for(int i=1;i<=l;i++)
if(!pp[i]){R++;cnt+=dfs(i);}
cout<<cnt<<'\n';
for(int i=1;i<=l;i++)
if(pp[i])cout<<i-1<<' '<<pp[i]-l-1<<'\n';
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 92ms
memory: 21608kb
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: 82ms
memory: 17108kb
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: 2ms
memory: 9852kb
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...