\quad对于每次查询(a,b),都去循环遍历图中每个点f,假设去掉这个点后a是否还能到b,如果去掉f后a不能到b,则f点一定被感染。这样的话时间复杂度为O(Q∗N∗(N+M))O(Q*N*(N+M))O(Q∗N∗(N+M)),可以过掉30%的数据。

#include <iostream>
#include <queue>
#include <vector>
using namespace std;const int N = 1010;
vector<int> E[N];
int vis[N];
int n, m;
// 看图中是否存在从a到b且不经过f的路径
bool haspath(int a, int b, int f)
{for(int i = 1; i <= n; i ++ ) vis[i] = 0;queue<int> q;q.push(a);vis[a] = 1;while(!q.empty()){int x = q.front();q.pop();if(x == b) return true;for(int y: E[x]){if(vis[y] == 1 || y == f) continue;q.push(y);vis[y] = 1;}}return false;
}int main()
{cin >> n >> m;for(int i = 0; i < m; i ++ ){int u, v; cin >> u >> v;E[u].push_back(v);E[v].push_back(u);}int Q; cin >> Q;while(Q -- ){int u, v; cin >> u >> v;int res = 2;// 依次去掉除了起点和终点的其他点后看看图中是否还存在一条从u到v的路,如果不存在的话则这个点必经过,需要在答案中+1for(int i = 1; i <= n; i ++ )if(i != u && i != v && !haspath(u, v, i)) res ++ ;cout << res << endl;}return 0;
}

Identifying Infected相关推荐

  1. R语言使用Rtsne包进行TSNE分析:提取TSNE分析结果合并到原dataframe中、可视化tsne降维的结果、并圈定降维后不匹配的数据簇(tSNE identifying mismatch)

    R语言使用Rtsne包进行TSNE分析:提取TSNE分析结果合并到原dataframe中.可视化tsne降维的结果.并使用两个分类变量从颜色.形状两个角度来可视化tsne降维的效果.并圈定降维后不匹配 ...

  2. This subject is anonymous - it does not have any identifying principals and authorization operations

    大家好,我是烤鸭: 最近使用shiro,遇到如下问题: 严重: Servlet.service() for servlet [dispatcherServlet] in context with pa ...

  3. 关于shiro授权 This subject is anonymous - it does not have any identifying principals and authorization

    在进行shiro前后分离授权时,报错如下. This subject is anonymous - it does not have any identifying principals and au ...

  4. Identifying App Installations

    Identifying App Installations 30 March 2011 [The contents of this post grew out of an internal discu ...

  5. ECCV2020 TIDE: A General Toolbox for Identifying Object Detection Errors

    ECCV2020 TIDE: A General Toolbox for Identifying Object Detection Errors论文翻译 摘要 1.介绍 2.工具 2.1 计算mAP ...

  6. 论文笔记:Identifying Lung Cancer Risk Factors in the Elderly Using Deep Neural Network - Chen, Wu

    论文笔记:Identifying Lung Cancer Risk Factors in the Elderly Using Deep Neural Network - Chen, Wu 原文链接 I ...

  7. A-Level经济例题解析及练习 Identifying a firm‘s profit

    今日知识点: Identifying a firm's profit 例题 Question: Identifying a firm's profit Determine this firm's to ...

  8. Identifying Singleton Spammers via Spammer Group Detection

    Identifying Singleton Spammers via Spammer Group Detection 目的:识别只发送了一次评论的spammer 探究隐藏的reviewer-produ ...

  9. Identifying genetic relatives without compromising privacy

    文章 He D, Furlotte N A, Hormozdiari F, et al. Identifying genetic relatives without compromising priv ...

最新文章

  1. 代码工具 | 数据清洗,试试这 8套Python代码
  2. RISC与CISC比较
  3. 程序出Bug,一定是环境的锅!
  4. 2.2 string
  5. 火狐浏览器添加MetaMask钱包和本地开启私有链开发
  6. python将数据存入mysql数据库中_python3 两种方法将数据存入mysql数据库
  7. 一堆数据中将某一个值相同的数据进行分组
  8. MYSQL端口自动开启的问题~
  9. 2014.10.1 Form中显示pdf文件
  10. 常用工具使用(sublimeText)
  11. win11开热点连接之后无网络解决方案
  12. 单代号网络图计算例题_海量优质网络图模板,轻巧实用的国产作图神器
  13. python 绘图英文字体_Python3实现英文字母转换哥特式字体实例代码
  14. TIMIT语音库下载以及语音库WAV转换相关问题
  15. fastadmin列表中,时间显示,格式设置
  16. 2022-2028全球昼夜节律性睡眠障碍行业调研及趋势分析报告
  17. 蓝桥杯练习题--Fibonacci数列
  18. 把ipad作为window系统电脑的扩展屏
  19. 用计算机弹起风了歌词,起风了歌词
  20. 2016-HitCon-Pwn-house_of_orange学习(附赠FSOP基础知识)

热门文章

  1. 项目管理系列---任务管理工具深度分析
  2. Chrome谷歌浏览器开发者工具调试:如何检查鼠标点击才显示失焦就隐藏的元素dom
  3. 用U盘进入有密码的Windows系统
  4. Python列表及如何使用列表元素
  5. Facebook 错误 不允许用户查看应用程序
  6. 哈希查找(根据电话号查找)
  7. Elasticsearch 平滑下线节点实践指南
  8. Google排名因素详解
  9. MySQL按照汉字的拼音排序(A-Z)
  10. sql server 2016 Always on 之 数据库处于恢复挂起状态