当前位置:网站首页>Acwing 379. hide and seek problem solution (minimum path non repeating point coverage)
Acwing 379. hide and seek problem solution (minimum path non repeating point coverage)
2022-07-26 02:06:00 【Mr. Qiao Da】
AcWing 379. hide-and-seek 
Big guy problem solving original address
#include<bits/stdc++.h>
using namespace std;
const int N = 210, M = 61000;
bool d[N][N], st[N];
int n, m;
int match[N];
bool find(int u){
for(int i = 1; i <= n; i ++ ){
// Traverse all points to see which can be connected
if(d[u][i] && !st[i]){
st[i] = true;
int t = match[i];
if(t == 0 || find(t)){
match[i] = u;
return true;
}
}
}
return false;
}
int main()
{
cin>>n>>m;
for(int i = 0; i < m; i ++ ){
int a, b;
cin>>a>>b;
d[a][b] = true;
}
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]; // Finding transitive closure , It is to connect a point on a road with all the points that can be connected behind
}
}
}
int res = 0;
for(int i = 1; i <= n; i ++ ){
memset(st, 0, sizeof st);
if(find(i)) res ++ ;
}
cout<<n - res <<endl;
return 0;
}
边栏推荐
- 重发布基础与配置
- Remember a laravel problem script @php artist package:discover handling the post autoload dump event returned with
- A pluggable am335x industrial control module onboard WiFi module
- Qt程序美化之样式表的使用方法,Qt使用图片作为背景与控件透明化,Qt自定义按钮样式
- 1205 Lock wait timeout exceeded; Try restarting transaction processing
- [in simple terms, play with FPGA learning 11 --- testbench writing skills 2]
- 1205 Lock wait timeout exceeded; try restarting transaction处理
- Build embedded development environment and FRP penetration under win
- pdf. JS introduction
- Why does the debugger display the wrong function
猜你喜欢

Niuke net question brushing training (I)

还在用==0 null equal 判断空值吗,对isEmpty 和 isBlank有多少了解呢

Worthington产气荚膜梭菌神经氨酸酶的特征及测定

PHP Alipay transfer to Alipay account

本地仓库导致的报错

How to use the pagoda panel to deploy the full stack project of node to the server

I.MX6UL核心模块使用连载-RTC测试 (十二)

How to choose cloud note tool? What can I do with cloud notes?

【2020】【论文笔记】磁控溅射法生长Bi2Te3/CoFeB双层异质结——

C# 迭代器的实现
随机推荐
还在用==0 null equal 判断空值吗,对isEmpty 和 isBlank有多少了解呢
转:高效做正确的事
DQN Pytorch示例
IDEA如何快速删除最近打开的项目
Protect syslog servers and devices
Qt程序美化之样式表的使用方法,Qt使用图片作为背景与控件透明化,Qt自定义按钮样式
CD from grabbing the track to building a streaming media server -- a case study of "moon in the hometown of sleep"
1. Mx6ul core module serial use - touch screen calibration (IX)
[in simple terms, play with FPGA learning 11 --- testbench writing skills 1]
[C language brush leetcode] 1462. curriculum IV (m)
Niuke - bm39 serialized binary tree [hard]
登堂入室soc之arm汇编基础
Excuse me, sir. Oracle to PG CDC Oracle, the upper case of the field is the same as that of PG
LeetCode302场周赛第三题--裁剪数字后查询第 K 小的数字
A MCU event driven C framework
Remember a laravel problem script @php artist package:discover handling the post autoload dump event returned with
[Verilog digital system design (Xia Yuwen) 4 ----- basic concepts of Verilog syntax 2]
How does Flink SQL configure to print the insert parameter log
Zhinai buys melons (DP backpack)
D - Dire Wolf (interval DP)