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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define F first
#define S second

int main(){
    FAST
    int n, m, k;
    cin >> n >> m >> k;
    int temp = n + m;
    m = k;
    n = temp;
    vector<int> adj[n];
    vector<pair<int, int> > ord;
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b;
        a--; b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }
    for(int i = 0; i < n; i++){
        ord.pb({adj[i].size(), i});
    }
    sort(ord.rbegin(), ord.rend());
    bool yes[n];
    mm(yes);
    int ans = 0;
    for(int i = 0; i < n; i++){
        int s = ord[i].second;
        bool ok = 0;
        for(int j = 0; j < adj[s].size(); j++){
            if(!yes[adj[s][j]]){
                ok = 1;
                break;
            }
        }
        if(ok){
            ans++;
            yes[s] = 1;
        }
    }
    cout << ans;
    return 0;
}
Copy
Min Vertex Cover 2 Basilhijaz
GNU G++17
56 ms
3.6 MB
Wrong Answer