题目传送门

 /*
图论/暴力:这是个连通的问题,每一次把所有度数为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的更多相关文章

  1. BFS Codeforces Beta Round #94 (Div. 2 Only) C. Statues

    题目传送门 /* BFS:三维BFS,坐标再加上步数,能走一个点当这个地方在步数内不能落到.因为雕像最多8步就会全部下落, 只要撑过这个时间就能win,否则lose */ #include <c ...

  2. 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 ...

  3. Codeforces Beta Round #94 (Div. 1 Only)B. String sam

    题意:给你一个字符串,找第k大的子字符串.(考虑相同的字符串) 题解:建sam,先预处理出每个节点的出现次数,然后处理出每个节点下面的出现次数,然后在dfs时判断一下往哪边走即可,注意一下num会爆i ...

  4. 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 ...

  5. 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 ...

  6. 暴力/DP Codeforces Beta Round #22 (Div. 2 Only) B. Bargaining Table

    题目传送门 /* 题意:求最大矩形(全0)的面积 暴力/dp:每对一个0查看它左下的最大矩形面积,更新ans 注意:是字符串,没用空格,好事多磨,WA了多少次才发现:( 详细解释:http://www ...

  7. Codeforces Beta Round #76 (Div. 2 Only)

    Codeforces Beta Round #76 (Div. 2 Only) http://codeforces.com/contest/94 A #include<bits/stdc++.h ...

  8. Codeforces Beta Round #80 (Div. 2 Only)【ABCD】

    Codeforces Beta Round #80 (Div. 2 Only) A Blackjack1 题意 一共52张扑克,A代表1或者11,2-10表示自己的数字,其他都表示10 现在你已经有一 ...

  9. Codeforces Beta Round #83 (Div. 1 Only)题解【ABCD】

    Codeforces Beta Round #83 (Div. 1 Only) A. Dorm Water Supply 题意 给你一个n点m边的图,保证每个点的入度和出度最多为1 如果这个点入度为0 ...

随机推荐

  1. C#内存管理—职场生存的必修课

    前言 在职场中,确立自身的技术水平很重要,因为,如果你被标记成了技术菜鸟,那么你的工作一旦做快了,大家就会一致的认为这个任务比较简单:如果你未如期完成,则会被各种明嘲暗讽,你不但无法获得合理的表扬,还 ...

  2. CentOS 6.X配置 NFS以及启动和mount挂载

    一.环境介绍: 服务器:centos 192.168.1.225 客户端:centos 192.168.1.226 二.安装: NFS的安装配置:centos 5 : yum -y install n ...

  3. long类型字段转换成varchar2类型

    參考文档: How to Convert a Long to Varchar2 (文档 ID 228532.1) /*long类型字段转换成varchar2类型*/ --建表 create table ...

  4. 使用JS对select标签进行联动选择

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/ ...

  5. 【iOS系列】-单例模式的实现

    1:重写allocWithZone方法 allocWithZone方法是对象分配内存空间时, alloc方法最终会调用这个方法 + (id)allocWithZone:(struct _NSZone ...

  6. 程序员的vim

    1,所有的Unix like系统都会内建vi文书编辑器,其他的文书编辑器则不一定会存在,但是目前我们使用比较多的是vim编辑器 vim具有程序编辑的能力,可以主动的以字体颜色辨别语法的正确性,方便程序 ...

  7. Django模板语言(二)

    1,装饰器:在不改变原函数的调用方式情况下为原函数增加一些功能(遵循开放封闭的原则) def outter(fn): def inner(*args, **kwargs): # 可以在执行函数前执行一 ...

  8. python iterable 和list、dictionary的区别和联系

    1 为什么一些函数的参数指定要iterable object的,但是也可以传入list为参数? 因为list.dictionary都是iterable object. 在iterable object ...

  9. sql 统计 url字符串处理

    SELECT SUBSTRING_INDEX(url,'/',1) AS wed_domain,COUNT(1),SUM(no_open_times),SUM(no_ad_times),SUM(ok_ ...

  10. HelloH5+搭建

    一.所用工具 代理服务器:squid 编辑工具:HBuilder 调试工具:weinre 参考工具:Hello MUI    HelloH5 二.涉及项目 ***-pifa-------------- ...