摄像头
来源:互联网 发布:牛黄解毒片 知乎 编辑:程序博客网 时间:2024/04/27 16:48
https://www.luogu.org/problem/show?pid=2712
拓扑排序嘛。每次找入度为零即没有被观测的摄像头砸掉,再把它所观测的摄像头的入度-1.
不过此题有一个特别坑的地方,就是摄像头的编号并不是1~n。
#include<iostream>#include<cstring>#include<string>#include<algorithm>#include<queue>#include<cstdio>#include<cmath> using namespace std;int n,maxn;int ru[1009],to[1009][1009]; bool f[1009];int main(){ scanf("%d",&n); for(int i=1;i<=n;i++) { int x,m; scanf("%d%d",&x,&m); for(int i=1;i<=m;i++) { int p;scanf("%d",&p); to[x][++to[x][0]]=p; ru[p]++; } f[x]=1; maxn=max(maxn,x); } int num=n; while(1) { int p=0; for(int i=1;i<=maxn;i++) if(f[i]==1&&ru[i]==0) {p=i;f[p]=0;break;} if(!p) break; for(int i=1;i<=to[p][0];i++) ru[to[p][i]]--; num--; } if(num) printf("%d",num); else printf("YES"); return 0; }
阅读全文
1 0
- 摄像头
- 摄像头
- 摄像头
- 摄像头
- 摄像头
- 摄像头
- 摄像头
- 摄像头
- 摄像头
- 摄像头
- 摄像头
- 摄像头
- 摄像头
- 摄像头
- 摄像头
- 摄像头
- 前置摄像头、后置摄像头
- 摄像头编程
- 一路(16)有你,一起(17)前行
- ES6语法学习阶段一:let和const 变量声明
- boost::bind 详解
- R语言逐行读取并处理大文件
- Windows 7 64位安装TenSorFlow
- 摄像头
- 摄像头
- 通过 STS 快速导入 Spring 官方示例项目
- Spring Aspect Oriented Programming
- vs2015 Microsoft.VsHub.Server.HttpHostx64.exe已停止工作问题
- 使用spring 管理原生jdbc的事務
- ctrl+c,ctrl+d,ctrl+z在linux程序中意义和区别 ctrl+c和ctrl+z都是中断命令,但是他们的作用却不一样. ctrl+c是强制中断程序的执行,,进程已经终止。 ct
- HTML 编辑器的介绍及推荐
- 剑指offer面试题[57]-删除链表中重复的结点