捉迷藏
最小路径重复点覆盖
#include <bits/stdc++.h>
using namespace std;
#define IO ios::sync_with_stdio(false);cin.tie(0); cout.tie(0)
inline int lowbit(int x) { return x & (-x); }
#define ll long long
#define ull unsigned long long
#define pb push_back
#define PII pair<int, int>
#define x first
#define y second
#define inf 0x3f3f3f3f
const int N = 210, M = 30010;
int n, m;
int match[N];
bool d[N][N], st[N];
bool find(int x) {
for (int i = 1; i <= n; ++i)
if (d[x][i] && !st[i]) {
st[i] = 1;
int t = match[i];
if (t == 0 || find(t)) {
match[i] = x;
return true;
}
}
return false;
}
int main() {
IO;
cin >> n >> m;
while (m--) {
int a, b;
cin >> a >> b;
d[a][b] = 1;
}
for (int k = 1; k <= n; ++k)
for (int i = 1; i <= n; ++i)
for (int j = 1; j <= n; ++j)
d[i][j] |= d[i][k] & d[k][j];
int res = 0;
for (int i = 1; i <= n; ++i) {
memset(st, 0, sizeof st);
if (find(i)) res++;
}
cout << n - res << '\n';
return 0;
}