为啥蓝题还有纯模板题啊 根本不知道他spj的点在哪 可惜了 本来考前一个小时觉得做不了一道蓝题 结果现在还剩半个多小时
不管了 CF去了
#include <bits/stdc++.h>
using namespace std;
const int N = 1010;
const int M = 1e4+10;
const int mod = 998244353;
#define int long long
#define endl '\n'
#define Endl '\n'
#define inf 0x3f3f3f3f3f3f3f3f
#define fast ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
int n1,n2,m,h[N],e[N<<1],ne[N<<1],idx,match[N<<1];
bool st[N<<1];
void add(int a,int b){
e[idx]=b;
ne[idx]=h[a];
h[a]=idx++;
}
int find(int x){
for(int i=h[x];~i;i=ne[i]){
int j=e[i];
if(!st[j]){
st[j]=true;
if(!match[j]||find(match[j])){
match[j]=x;
return true;
}
}
}
return false;
}
signed main(){
fast
cin>>n1>>m;
n2=m-n1;
memset(h,-1,sizeof h);
while(1){
int a,b;cin>>a>>b;
if(a==-1&&b==-1)break;
add(a,b);
}
int ans=0;
for(int i=1;i<=n1;i++){
memset(st,0,sizeof st);
if(find(i))ans++;
}
cout<<ans<<endl;
for(int i=1;i<=m;i++){
if(match[i])cout<<match[i]<<' '<<i<<endl;
}
return 0^0;
}