Source Code
#include<bits/stdc++.h>
#define ll long long 

using namespace std;
ll MOD = 1e9+7;
ll bigMod(ll x,ll y){
    if (y == 1)return x;
    ll res = bigMod(x , y / 2LL);
    res *= res;
    res %= MOD;
    if (y % 2){
        res *= x;
        res %= MOD;
    }
    return res;
}

int n , m , k;
int vis[100005];
int cnt[100005];
vector<int> v[200005];
int main()
{
    ios::sync_with_stdio(0);
    cin >> n >> m >> k;
    int cntl=0;
    for (int i=0;i<k;i++){
        int l,r;
        cin >> l >> r;
        v[l].push_back(r + n);
        v[r+n].push_back(l);
        if(v[l].size() == 1)cntl++;
    }
    int ans = cntl;
    for (int i=n+1;i<=n+m;i++){
        int cur = 0;
        for (int u : v[i]){
            if (v[u].size() == 1)cur++;
        }
        ans = min(ans , cntl - cur + 1);
    }
    cout << ans << endl;

    return 0;
}
Copy
Min Vertex Cover 1 Khaled97ha
GNU G++17
106 ms
9.6 MB
Accepted