题目传送门

 /*
暴力:也是暴力过了,无语。无向图,两端点都要加度数和点
*/
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <cmath>
using namespace std; typedef long long ll;
const int MAXN = 2e2 + ;
const int INF = 0x3f3f3f3f;
ll a[MAXN];
vector<int> G[MAXN];
int degree[MAXN]; int main(void) //hihoCoder 1179 永恒游戏
{
// freopen ("C.in", "r", stdin); int n, m;
while (scanf ("%d%d", &n, &m) == )
{
for (int i=; i<n; ++i) scanf ("%lld", &a[i]);
for (int i=; i<n; ++i) G[i].clear ();
memset (degree, , sizeof (degree));
while (m--)
{
int u, v; scanf ("%d%d", &u, &v);
degree[u]++; degree[v]++;
G[u].push_back (v); G[v].push_back (u);
} bool ok = false;
for (int i=; i<=; ++i)
{
ok = false;
for (int j=; j<n; ++j)
{
if (a[j] >= degree[j])
{
for (int k=; k<G[j].size (); ++k)
{
a[j]--; a[G[j][k]]++;
}
ok = true; break;
}
}
if (!ok) {printf ("%d\n", i - ); break;}
}
if (ok) puts ("INF");
} return ;
}

最新文章

  1. 使用 IntelliJ IDEA 导入 Spark源码及编译 Spark 源代码
  2. Spring的beans标签下可以有其他标签
  3. phalcon: model 验证数据完整性
  4. 【转载】JSP中文乱码问题
  5. C# 时间函数
  6. Buns(dp+多重背包)
  7. (原) Jquery 判断设备是PC端,还是移动端
  8. 将时间显示为“刚刚”“n分钟/小时前”等
  9. Python学习笔记——基础篇【第五周】——random &amp; time &amp; datetime模块
  10. 文件上传----FTP部署
  11. Linux安装网易云音乐
  12. ROM、RAM、DRAM、SRAM和FLASH、PSRAM
  13. my read travel
  14. mysql储存引擎
  15. MT【198】连乘积放缩
  16. bzoj千题计划121:bzoj1033: [ZJOI2008]杀蚂蚁antbuster
  17. 1083 Cantor表
  18. 前端bootstrap框架禁用响应式的方法
  19. Spring Bean作用域实例
  20. Ubuntu16.04以root身份登入!

热门文章

  1. influxDB系列(一)
  2. Centos 6.x 安装Nagios及WEB管理nagiosql实现windows及linux监控指南
  3. 基于RTP的h.264视频传输系统设计(一)
  4. Office EXCEL 如何保留一位小数,并且单击这个单元格的时候没有一大串小数
  5. Deepin-安装php
  6. iOS iOS8中 问题&amp;quot;registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later&amp;quot; 解决方式
  7. 2016/05/06 Sublime Text 3 常用插件以及安装方法(转)
  8. Codeforces Round #412 (rated, Div. 2, base on VK Cup 2017 Round 3) E. Prairie Partition 二分+贪心
  9. IntentFilter打印方法
  10. ABAP 邮件