Source Code
#include <bits/stdc++.h>
using namespace std;

const int N = 100010;

int n , m , k;

int cur[N];

vector< int > g[N];

int main(){
    scanf("%d%d%d",&n,&m,&k);
    for(int l , r , i = 0 ;i < k;i++){
        scanf("%d%d",&l,&r);
        g[r].push_back(l);
        cur[l]++;
    }
    int a = 0 , b = 0;
    for(int i = 1;i <= n;i++) if(cur[i] > 0) a++;
    for(int i = 1;i <= m;i++) if((int)g[i].size() > 0) b++;
    int ans = a;
    for(int now , i = 1;i <= m;i++){
        now = 0;
        for(int j = 0 ;j < (int)g[i].size();j++){
            if(cur[g[i][j]] == 1)
                now++;
        }
        ans = min(ans , a - now);
    }
    cout << ans << endl;

}
Copy
Min Vertex Cover 1 Kilani
GNU G++17
6 ms
2.8 MB
Wrong Answer