当前位置:网站首页>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;
}
边栏推荐
- How to do Taobao live broadcast and how to do the anchor to drain and sell products
- D - Dire Wolf (interval DP)
- 1. Mx6ul core module serial use - touch screen calibration (IX)
- MPLS knowledge points
- Worthington产气荚膜梭菌神经氨酸酶的特征及测定
- 保护系统日志服务器和设备
- Mark and lightbulbs (thinking)
- IDEA如何快速删除最近打开的项目
- The slow loading of the first entry page of vite local operation
- [C language brush leetcode] 1604. Warn people who use the same employee card more than or equal to three times within an hour (m)
猜你喜欢

SQL手工盲注、报错注入

Sqlyog data import and export graphic tutorial

Ti AM335X工控模块使用beaglebone(bbb)的Debian系统

Navica工具把远程MySQL导入到本地MySQL数据库

I.MX6UL核心模块使用连载-nand flash读写测试 (三)

IDEA如何快速删除最近打开的项目
![[paper reading] coat: CO scale conv attentional image transformers](/img/d4/13ac8cdce07999d4fd51aa23173190.png)
[paper reading] coat: CO scale conv attentional image transformers

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

一款可插拔的AM335X工控模块板载wifi模块

餐饮连锁门店重塑增长背后的数字化转型
随机推荐
How idea can quickly delete recently opened projects
Leetcode/ numbers that appear only once
[C language brush leetcode] 146. LRU cache (m)
How to use the pagoda panel to deploy the full stack project of node to the server
DQN Pytorch示例
MPLS知识点
PHP Alipay transfer to Alipay account
Niuke - bm39 serialized binary tree [hard]
Characteristics and determination of neuraminidase from Clostridium perfringens in Worthington
[in simple terms, play with FPGA learning 11 --- testbench writing skills 1]
国标GB28181协议视频平台EasyGBS消息弹框模式优化
Proto conversion dart | project uses protobuf | fluent uses grpc
IDEA如何快速删除最近打开的项目
The slow loading of the first entry page of vite local operation
I.MX6UL核心模块使用连载-TF卡读写测试 (五)
[C language brush leetcode] 814. Binary tree pruning (m)
Worthington产气荚膜梭菌神经氨酸酶的特征及测定
[leetcode] 32. Longest valid bracket
Navica工具把远程MySQL导入到本地MySQL数据库
重发布基础与配置