题目传送门

 /*
图论/暴力:这是个连通的问题,每一次把所有度数为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. Deepin-安装(读写文件)权限

    在安装NODE管理模块N时,遇到了权限问题 1.给予程序读写权限(仅限文件夹) 查看权限:ls -l 或 ls 添加权限: 示例:chmod +rw xx 实例:chmod +rw node 关于权限 ...

  2. instancetype VS id

    英文好的直接读下面链接的文章就好了: http://stackoverflow.com/questions/8972221/would-it-be-beneficial-to-begin-using- ...

  3. 使用python生成c文件模板

    目标 完成一个python脚本,实现指定名字后,自动生成.c和.h的模板.例如: /** * @file epc.c * @author 陈维 * @version V01 * @date 2017. ...

  4. hdu2222--Keywords Search+AC自己主动机模板

    题目链接:pid=2222">点击进入 KMP对模式串进行处理.然后就能够方便的推断模式串是否在目标串中出现了:这显示适合一个模式串多个目标串的情况.可是假设模式串有多个,这时假设还用 ...

  5. iOS 用xib自定义View

      网上有很多关于实现用xib自定义View,那我为什么还要写呢?第一,我用他们的方法都没有实现.第二,用xib遇到了很多问题,想分享给大家.    用xib自定义View:FHCustomView ...

  6. centos7 配置虚拟交换机(物理交换机truckport设置)(使用brctl)

    感谢朋友支持本博客.欢迎共同探讨交流,因为能力和时间有限.错误之处在所难免,欢迎指正! 假设转载,请保留作者信息. 博客地址:http://blog.csdn.net/qq_21398167 原博文地 ...

  7. druid 参考配置

    mysql <!-- 配置druid连接池 --> <context:property-placeholder location="classpath:jdbc.prope ...

  8. 'cmd' 不是内部或外部命令,也不是可运行的程序 或批处理文件。

    'cmd' 不是内部或外部命令,也不是可运行的程序或批处理文件. Path 添加 %SystemRoot%/system32;%SystemRoot%;%SystemRoot%/System32/Wb ...

  9. 反爬统计 数据库 sql CASE

    -- 经排查日志,发现ordertest.com下的url检测,频繁<Response [403]>,Forbidden;再进一步查询数据库数据:逐日统计错误临时表test_error_t ...

  10. 牛客练习赛13D:幸运数字Ⅳ(康托展开) F:关键字排序

    链接:https://www.nowcoder.com/acm/contest/70/D 题目: 定义一个数字为幸运数字当且仅当它的所有数位都是4或者7. 比如说,47.744.4都是幸运数字而5.1 ...