【AtCoder ABC 075 C】Bridge
【链接】 我是链接,点我呀:)
【题意】
让你求出桥的个数
【题解】
删掉这条边,然后看看1能不能到达其他所有的点就可以了
【代码】
#include <bits/stdc++.h>
using namespace std;
const int M = 50;
int n, m,g[M+10][M+10];
pair<int, int> a[M+10];
bool bo[M + 10];
void dfs(int x)
{
if (bo[x]) return;
bo[x] = true;
for (int i = 1;i <= n;i++)
if (i!=x && g[x][i])
dfs(i);
}
int main()
{
//freopen("F:\\rush.txt", "r", stdin);
scanf("%d%d", &n, &m);
for (int i = 1; i <= m; i++)
{
int x, y;
scanf("%d%d", &x, &y);
g[x][y] = g[y][x] = 1;
a[i] = make_pair(x, y);
}
int ans = 0;
for (int i = 1; i <= m; i++)
{
g[a[i].first][a[i].second] = 0;
g[a[i].second][a[i].first] = 0;
for (int j = 1; j <= n; j++) bo[j] = 0;
dfs(1);
int ok = false;
for (int j = 1; j <= n; j++)
if (bo[j] == 0)
ok = 1;
ans += ok;
g[a[i].first][a[i].second] = 1;
g[a[i].second][a[i].first] = 1;
}
printf("%d\n", ans);
return 0;
}
【AtCoder ABC 075 C】Bridge的更多相关文章
- 【AtCoder ABC 075 D】Axis-Parallel Rectangle
[链接] 我是链接,点我呀:) [题意] 让你找到一个各边和坐标轴平行的矩形.使得这个矩形包含至少K个点. 且这个矩形的面积最小. [题解] 把所有的"关键点""都找出来 ...
- 【AtCoder ABC 075 B】Minesweeper
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 模拟,把#换成1 八个方向加一下就好. [代码] #include <bits/stdc++.h> using name ...
- 【AtCoder ABC 075 A】One out of Three
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 用map轻松搞定 [代码] #include <bits/stdc++.h> using namespace std; ...
- 【AtCoder Regular Contest 082】Derangement
[链接]点击打开链接 [题意] 在这里写题意 [题解] 贪心. 连续一块的p[i]==i的话,对答案的贡献就应该为(这个连续块的长度+1)/2; 长度为1的也正确. (也即两两相邻的互换位置.) [错 ...
- 【Atcoder hbpc C 183】1=0.999...
Atcoder hbpc C 题意:给n个循环小数或者有限小数,问其中有多少个互不相同的. 思路:我的思路比较繁琐. 首先我们考虑分数化小数:假设原来的数是\(a.b(c)\),那么这个分数就是\(a ...
- 【csp模拟赛3】bridge.cpp--矩阵加速递推
题目描述 穿越了森林,前方有一座独木桥,连接着过往和未来(连接着上一题和下一题...). 这座桥无限长. 小 Q 在独木桥上彷徨了.他知道,他只剩下了 N 秒的时间,每一秒的时间里,他会向 左或向右移 ...
- 【AtCoder Regular Contest 080E】Young Maids [堆][线段树]
Young Maids Time Limit: 50 Sec Memory Limit: 512 MB Description 给定一个排列,每次选出相邻的两个放在队头,要求字典序最小. Input ...
- 【AtCoder Grand Contest 007E】Shik and Travel [Dfs][二分答案]
Shik and Travel Time Limit: 50 Sec Memory Limit: 512 MB Description 给定一棵n个点的树,保证一个点出度为2/0. 遍历一遍,要求每 ...
- 【AtCoder Grand Contest 001F】Wide Swap [线段树][拓扑]
Wide Swap Time Limit: 50 Sec Memory Limit: 512 MB Description Input Output Sample Input 8 3 4 5 7 8 ...
随机推荐
- LinkedIn微服务框架rest.li
linkedin/rest.li https://github.com/linkedin/rest.li LinkedIn微服务框架rest.li摘要:Rest.li是一款REST+JSON框架,使 ...
- 8.ZOrder
T3LayerZorder.h #pragma once #include "cocos2d.h" USING_NS_CC; class T3LayerZorder:public ...
- Spring3 整合MyBatis3 配置多数据源 动态选择SqlSessionFactory(转)
1. Spring整合MyBatis切换SqlSessionFactory有两种方法,第一. 继承SqlSessionDaoSupport,重写获取SqlSessionFactory的方法.第二.继承 ...
- PatentTips - Improving security in a virtual machine host
BACKGROUND Computer viruses are a common problem for computer users. One typical mode of attack is t ...
- C# 的时间戳 在flash actionscript中使用
眼下在做一个项目,要以字节的方式传时间戳到flash中, 错误的就不写了.仅仅写一个能够使用的例如以下: C# DateTime centuryBegin = new DateTime(1970, 1 ...
- [Redux-Observable && Unit Testing] Use tests to verify updates to the Redux store (rxjs scheduler)
In certain situations, you care more about the final state of the redux store than you do about the ...
- wordpress 加速主题的静态资源
wordpress 加速主题的静态资源(固定的CSS.JS和图片等) wordpress 中用函数 get_stylesheet_directory_uri() 生成当前主题的 URL , 格式如 h ...
- (转)Tomcat文件详解
做web项目,最常用的服务器就是Apache的tomcat.虽然一直在用tomcat,但都是仅限在使用的阶段,一直没有深入学习过.想深入学习tomcat,首推的肯定是官网:http://tomcat. ...
- CSRF Failed: Referer checking failed - no Referer
postman模拟登录出了这个错误,其实看标题就知道大概是怎么回事,网上大概找了办法,也没说到位,所以干脆自己找源码了. 问题很明显就是出在 CSRF 上,理所当然去查看 CsrfViewMiddle ...
- C++ 复制到粘贴板
网上好多教程讲如何复制到剪切板,但是有可能复制的是乱码,为了方便,将CString类型的复制到剪切板 CString source;if (OpenClipboard()){//防止非ASCII语言复 ...