图论/暴力 Codeforces Beta Round #94 (Div. 2 Only) B. Students and Shoelaces
/*
图论/暴力:这是个连通的问题,每一次把所有度数为1的砍掉,把连接的点再砍掉,总之很神奇,不懂:)
*/
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std; const int MAXN = 1e2 + ;
const int INF = 0x3f3f3f3f;
int cnt[MAXN];
int a[MAXN];
bool g[MAXN][MAXN]; int main(void) //Codeforces Beta Round #94 (Div. 2 Only) B. Students and Shoelaces
{
// freopen ("B.in", "r", stdin);
int n, m;
while (scanf ("%d%d", &n, &m) == )
{
memset (cnt, , sizeof (cnt));
memset (g, false, sizeof (g));
for (int i=; i<=m; ++i)
{
int x, y; scanf ("%d%d", &x, &y);
cnt[x]++; cnt[y]++;
g[x][y] = g[y][x] = true;
} int t = ; int ans = -;
do{
t = ;
for (int i=; i<=n; ++i)
{
if (cnt[i] == ) {cnt[i]--; a[++t] = i;}
}
for (int i=; i<=t; ++i)
{
for (int j=; j<=n; ++j)
{
if (g[a[i]][j] == true) cnt[j]--;
}
}
++ans;
}while (t > ); printf ("%d\n", ans);
} return ;
} /*
3 3
1 2
2 3
3 1
6 3
1 2
2 3
3 4
6 5
1 4
2 4
3 4
5 4
6 4
*/
图论/暴力 Codeforces Beta Round #94 (Div. 2 Only) B. Students and Shoelaces的更多相关文章
- BFS Codeforces Beta Round #94 (Div. 2 Only) C. Statues
题目传送门 /* BFS:三维BFS,坐标再加上步数,能走一个点当这个地方在步数内不能落到.因为雕像最多8步就会全部下落, 只要撑过这个时间就能win,否则lose */ #include <c ...
- Codeforces Beta Round #94 div 2 B
B. Students and Shoelaces time limit per test 2 seconds memory limit per test 256 megabytes input st ...
- Codeforces Beta Round #94 (Div. 1 Only)B. String sam
题意:给你一个字符串,找第k大的子字符串.(考虑相同的字符串) 题解:建sam,先预处理出每个节点的出现次数,然后处理出每个节点下面的出现次数,然后在dfs时判断一下往哪边走即可,注意一下num会爆i ...
- Codeforces Beta Round #94 div 1 D Numbers map+思路
D. Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...
- Codeforces Beta Round #94 div 2 C Statues dfs或者bfs
C. Statues time limit per test 2 seconds memory limit per test 256 megabytes input standard input ou ...
- 暴力/DP Codeforces Beta Round #22 (Div. 2 Only) B. Bargaining Table
题目传送门 /* 题意:求最大矩形(全0)的面积 暴力/dp:每对一个0查看它左下的最大矩形面积,更新ans 注意:是字符串,没用空格,好事多磨,WA了多少次才发现:( 详细解释:http://www ...
- Codeforces Beta Round #76 (Div. 2 Only)
Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...
- Codeforces Beta Round #80 (Div. 2 Only)【ABCD】
Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...
- Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】
Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...
随机推荐
- C++ std::tr1::bind使用
1. 简述 同function函数相似.bind函数相同也能够实现相似于函数指针的功能.但却却比函数指针更加灵活.特别是函数指向类 的非静态成员函数时.std::tr1::function 能够对静态 ...
- hdu 3624 City Planning(暴力,也可扫描线)
City Planning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) To ...
- 基于Spring-SpringMVC-Mybatis的简单样例
复习下 好久没搞过撸过代码了! 这个样例包括一个完整的增删改查! 源代码地址http://download.csdn.net/detail/wangdianyong/8909903
- OpenCV实践之路——Python的安装和使用
本文由@星沉阁冰不语出品,转载请注明作者和出处. 文章链接:http://blog.csdn.net/xingchenbingbuyu/article/details/50936076 微博:http ...
- Hibernate 之 How
分享自: http://blog.csdn.net/jnqqls/article/details/8242520 在上一篇文章Hibernate 之 Why? 中对Hibernate有了一个初步的了解 ...
- C 编程中fseek、ftell的用法总结
fseek 函数功能是将文件指针移动到指定的地方,因此可以通过fseek重置文件指针的位置.函数原型: int fseek(FILE *stream, long offset, int origi ...
- Delphi中accesss实现树形结构查询系统(一次性生成比较方便)
主要是要读取数据库的信息,而delphi界面是一个树形结构. 例如有一个Ascess数据库:示例.MDB,内有一张表:“国家”,表的内容如下: 编号 名称 01 ...
- Delphi全角转半角
function ToDBC( input :String):WideString;varc:WideString;i:Integer;beginc := input;for i:=1 to Leng ...
- linux网络socket 接口转
linux网络socket 接口 1.socket函数:一个进程必须做的第一件事就是调用socket函数获得一个文件描述符. ------------------------------------- ...
- js验证form表单示例
js验证form表单示例 检测测试了js表单验证,无jQuery(简单的功能有时无需jQuery版本) js代码如下: <script type="text/javascript& ...