题目大意:求一颗基环树的最小点覆盖。

题解:其实是一道比较板子的树形dp,dp[i][0/1]表示取或者不取i点的最小点。但是首先我们要把基环树断开,然后分别考虑a被覆盖和b被覆盖的情况。

dp[i][0]=∑min(dp[j][0],dp[j][1])

d p [ i ] [ 1 ] = ∑ d p [ j ] [ 0 ]

AC_code:

 1 int dp[maxn][3];
2 int a,b,flag;
3 vector<int>g[maxn];
4 void dfs(int x,int fa){
5 dp[x][0]=dp[x][1]=0;
6 for(int i=0;i<g[x].size();i++){
7 int v=g[x][i];
8 if(fa==v) continue;
9 dfs(v,x);
10 dp[x][0]+=min(dp[v][0],dp[v][1]);
11 dp[x][1]+=dp[v][0];
12 }
13 dp[x][0]++;
14 if(x==b&&flag==2) dp[x][1]=dp[x][0];
15 }
16 void run(){
17 int n=rd(),m=rd();
18 rep(i,1,n+m){
19 int x=rd(),y=rd();
20 if(!flag&&x<n&&y<n){
21 a=x,b=y;
22 flag=1;
23 continue;
24 }
25 g[x].push_back(y);
26 g[y].push_back(x);
27 }
28 int ans=inf;
29 flag=1;
30 dfs(a,-1);
31 ans=min(dp[a][0],ans);
32 flag=2;
33 dfs(a,-1);
34 ans=min(ans,min(dp[a][0],dp[a][1]));
35 printf("%d\n",ans);
36 }

Cable Protection的更多相关文章

  1. POJ 1966 Cable TV Network

    Cable TV Network Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 4702   Accepted: 2173 ...

  2. ASP.NET Core 数据保护(Data Protection 集群场景)【下】

    前言 接[中篇],在有一些场景下,我们需要对 ASP.NET Core 的加密方法进行扩展,来适应我们的需求,这个时候就需要使用到了一些 Core 提供的高级的功能. 本文还列举了在集群场景下,有时候 ...

  3. ASP.NET Core 数据保护(Data Protection)【中】

    前言 上篇主要是对 ASP.NET Core 的 Data Protection 做了一个简单的介绍,本篇主要是介绍一下API及使用方法. API 接口 ASP.NET Core Data Prote ...

  4. ASP.NET Core 数据保护(Data Protection)【上】

    前言 上一篇博客记录了如何在 Kestrel 中使用 HTTPS(SSL), 也是我们目前项目中实际使用到的. 数据安全往往是开发人员很容易忽略的一个部分,包括我自己.近两年业内也出现了很多因为安全问 ...

  5. MacOS changed System Integrity Protection status

    禁止 System Integrity Protection 按住 command + R 重启系统 进入单用户模式 启动bash工具: 输入: csrutil disable 输入:reboot 启 ...

  6. "System Protection" is disabled in Win10 default settings

    We could find some important clue in Restore Point because "System Protection" of volume C ...

  7. 挖掘机力矩限制器/挖掘机称重系统/挖泥机称重/Excavators load protection/Load moment indicator

    挖掘机力矩限制器是臂架型起重机机械的安全保护装置,本产品采用32位高性能微处理器为硬件平台 ,软件算法采用国内最先进的液压取力算法,该算法吸收多年的现场经验,不断改进完善而成.本产品符合<GB1 ...

  8. Process Kill Technology && Process Protection Against In Linux

    目录 . 引言 . Kill Process By Kill Command && SIGNAL . Kill Process By Resource Limits . Kill Pr ...

  9. POJ 1064 Cable master (二分)

    题目链接: 传送门 Cable master Time Limit: 1000MS     Memory Limit: 65536K 题目描述 有N条绳子,它们长度分别为Li.如果从它们中切割出K条长 ...

随机推荐

  1. C# Arrays

    Arrays 数组是一系列items 的集合,可以进行各种操作,比如sorting等 定义方式: 数据类型[] 数组名; 使用之前需要实例化,这就是实例化了一个含有2个元素的string 数组 还记得 ...

  2. git操作是出现Username for 'https://github.com':的验证问题

    Username for 'https://github.com': 输入的是github上的邮箱账号, 而不是github中设置的username, 这是个巨坑!!!Password for 'ht ...

  3. Mybatis基础:Mybatis映射配置文件,Mybatis核心配置文件,Mybatis传统方式开发

    一.Mybatis快速入门 1.1 框架介绍 框架是一款半成品软件,我们可以基于这个半成品软件继续开发,来完成我们个性化的需求! 框架:大工具,我们利用工具,可以快速开发项目 (mybatis也是一个 ...

  4. React.createClass vs. ES6 Class Components

    1 1 1 https://www.fullstackreact.com/articles/react-create-class-vs-es6-class-components/ React.crea ...

  5. 微信小程序-导航 & 路由

    微信小程序-导航 & 路由 页面跳转 页面路由 页面栈, 框架以栈的形式维护了当前的所有页面. https://developers.weixin.qq.com/miniprogram/dev ...

  6. 前端 vs 后端

    前端 vs 后端 前端与后端: 有什么区别? 前端和后端是计算机行业中最常用的两个术语. 在某种程度上,它们成了流行语. 它们决定了您作为软件开发人员所从事的工作类型,所使用的技术以及所获得的收入. ...

  7. React useMemo

    React useMemo react hooks https://reactjs.org/docs/hooks-reference.html#usememo useCallback & us ...

  8. web effects collection

    web effects collection typewriter effect js 打字机效果 http://www.mattboldt.com/demos/typed-js/ https://g ...

  9. webpack loader & pulgin

    webpack loader & plugin https://webpack.js.org/concepts/loaders/ https://webpack.js.org/concepts ...

  10. Apache 低版本不支持 WebSocket

    Apache 低版本不支持 WebSocket Apache HTTP Server Version 2.4 Apache Module mod_proxy_wstunnel https://http ...