题面

Luogu

Sol

弦图最大独立集

做法见上篇博客

# include <bits/stdc++.h>
# define RG register
# define IL inline
# define Fill(a, b) memset(a, b, sizeof(a))
using namespace std;
const int _(205);
typedef long long ll; IL int Input(){
RG int x = 0, z = 1; RG char c = getchar();
for(; c < '0' || c > '9'; c = getchar()) z = c == '-' ? -1 : 1;
for(; c >= '0' && c <= '9'; c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
return x * z;
} int n, m, first[_], cnt, label[_], vis[_], ans, best, Q[_];
struct Edge{
int to, next;
} edge[_ * _];
vector <int> P[_]; IL void Add(RG int u, RG int v){
edge[cnt] = (Edge){v, first[u]}, first[u] = cnt++;
} int main(RG int argc, RG char* argv[]){
Fill(first, -1), Q[0] = n = Input(), m = Input();
for(RG int i = 1; i <= m; ++i){
RG int u = Input(), v = Input();
Add(u, v), Add(v, u);
}
for(RG int i = 1; i <= n; ++i) P[0].push_back(i);
for(RG int i = 1, nw; i <= n; ++i){
for(RG int flg = 0; !flg; ){
for(RG int j = P[best].size() - 1; ~j; --j){
if(vis[P[best][j]]) P[best].pop_back();
else{
nw = P[best][j], flg = 1;
break;
}
}
if(!flg) --best;
}
vis[nw] = 1, Q[Q[0]--] = nw;
for(RG int e = first[nw]; e != -1; e = edge[e].next)
if(!vis[edge[e].to]){
P[++label[edge[e].to]].push_back(edge[e].to);
best = max(best, label[edge[e].to]);
}
}
Fill(vis, 0);
for(RG int i = 1; i <= n; ++i){
if(vis[Q[i]]) continue;
++ans, vis[Q[i]] = 1;
for(RG int e = first[Q[i]]; e != -1; e = edge[e].next)
vis[edge[e].to] = 1;
}
printf("%d\n", ans);
return 0;
}

最新文章

  1. Lumia 830 win10m 启用触摸按键
  2. SAP和Java系统的Webservice实例
  3. 如何向AcmeAir注入问题代码
  4. 16g u盘变 成1g u盘 解决方案,使用驱动器中的光盘之前需要将其格式化
  5. 百度前端笔试题目--css 实现一个带尖角的正方形
  6. TCP/IP-协议族----17、应用层简单
  7. GTK+2.0学习——第一个GTK程序
  8. 前端开发必备之Chrome开发者工具(一)
  9. Python_迭代器-生成器-复习-习题_41
  10. Maven Return code is: 401
  11. python爬虫之分析Ajax请求抓取抓取今日头条街拍美图(七)
  12. Dockerfile编写的注意事项
  13. mysql 主从复制change master to
  14. Myeclipse2013破解方法
  15. mfc CSpinButton
  16. sql server内置存储过程、查看系统信息
  17. swoole udp
  18. Objective-C和Swift混合编程开发
  19. page指令属性简要介绍:
  20. 自定义属性之LinearLayout ImageView TextView模拟图片文字按钮

热门文章

  1. 对cors的理解
  2. Shell基本知识
  3. 自己写的第一个Schema文件
  4. oracle nvl()函数
  5. Java编码转换
  6. 数组合并去重Array.from
  7. 论文阅读 | FPN:Feature Pyramid Networks for Object Detection
  8. oracle12c之二 控制PDB中SGA 与 PGA 内存使用
  9. 关于typedef的用法
  10. (转)使用LVS实现负载均衡原理及安装配置详解