rt,写的二分图最大匹配
#include<bits/stdc++.h>
#define int long long
#pragma GCC optimeze(2)
#pragma GCC optimeze(3)
#define lowbit(x) (x&(-x))
#define fi first
#define PII pair<int,int>
#define se second
#define pu(x) push_back(x)
using namespace std;
const int N=10005;
const int M=1e6+5;
int read() {
int x=0,flag=1;
char ch=0;
while(ch<'0'||ch>'9') {
if(ch=='-')flag=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9') {
x=(x<<1)+(x<<3)+ch-'0';
ch=getchar();
}
return flag*x;
}
void write(int x) {
if(x<0)putchar('-'),x=-x;
static int sta[35];
int top = 0;
do {
sta[top++] = x % 10, x /= 10;
} while (x);
while (top) putchar(sta[--top] + 48);
}
int n,head[N],ne[M*2],ver[M*2],tot,ma[M],bj[M];
void add(int x,int y){
ver[++tot]=y,ne[tot]=head[x],head[x]=tot;
}
bool match(int x){
// cout<<"TEST "<<x<<endl;
for(int i=head[x];i;i=ne[i]){
int to=ver[i];
// cout<<to<<endl;
if(bj[to]!=x){
bj[to]=x;
if(!ma[to]||match(ma[to])){
ma[to]=x;
return true;
}
}
}
return false;
}
signed main() {
n=read();
for(int i=1;i<=n;i++){
int u=read(),v=read();
add(u,i),add(v,i);
}
for(int i=1;i<=10000;i++){
if(!match(i)){
cout<<i-1;
return 0;
}
}
cout<<10000;
return 0;
}