csu oj Infected Computer 1427
#include <iostream>
#include <algorithm>
#include <stdio.h>
#define max 20005
#define ll long long
using namespace std; struct G{
int from;
int to;
ll time;
}game[max]; bool graf[max]; bool cmp(G a,G b){
return a.time < b.time;
}
int main()
{
int n,m;
while(cin>>n>>m){
for(int i = ;i < max;i++){
graf[i]=false;
game[i].time=game[i].from=game[i].to=;
}
graf[]=true; for(int i = ;i < m;i++){
cin>>game[i].time>>game[i].from>>game[i].to;
}
sort(game,game+m,cmp); bool flag = false;
for(int i = ;i < m;i++){
if(game[i].from==){
flag = true;
//graf[game[i].to] = true;
}
if(flag&&graf[game[i].from]){
graf[game[i].to] = true;
}
}
ll ans = ;
for(int i = ;i <= n;i++){
if(graf[i])ans++;
}
cout<<ans<<endl;
}
return ;
}
如果非要给划分,我想应该是属于并查集一类的
csu oj Infected Computer 1427的更多相关文章
- csu oj 1339: 最后一滴血
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1339 1339: 最后一滴血 Time Limit: 1 Sec Memory Limit: 1 ...
- csu oj 1330 字符识别?
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1330 1330: 字符识别? Time Limit: 1 Sec Memory Limit: 1 ...
- csu oj 1811: Tree Intersection (启发式合并)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1811 给你一棵树,每个节点有一个颜色.问删除一条边形成两棵子树,两棵子树有多少种颜色是有 ...
- csu oj 1804: 有向无环图 (dfs回溯)
题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1804 中文题意就不说了. dfs从底到根回溯即可,看代码应该能清楚. //#pragma ...
- csu oj 1344: Special Judge
Description Given a positive integer n, find two non-negative integers a, b such that a2 + b2 = n. I ...
- csu oj 1343 Long Long
Description 现在有两个单调递增序列,第一个序列有N个整数,第二个序列有M个整数,现在你可以从第一个序列中选一个数x,然后从第二个序列中选一个数y,那么有多少种情况满足x+y<=K呢? ...
- csu oj 1341 string and arrays
Description 有一个N*N的字符矩阵,从上到下依次记为第1行,第2行,……,第N行,从左至右依次记为第1列,第2列,……,第N列. 对于这个矩阵会进行一系列操作,但这些操作只有两类: (1) ...
- CSU OJ 1340 A Sample Problem
Description My girlfriend loves 7 very much, she thinks it is lucky! If an integer contains one or m ...
- CSU OJ PID=1514: Packs 超大背包问题,折半枚举+二分查找。
1514: Packs Time Limit: 10 Sec Memory Limit: 128 MBSubmit: 61 Solved: 4[Submit][Status][Web Board] ...
随机推荐
- 最近用到mysql和mybatis结合常用的知识点坐下整理
1.当用到集合in(x,x...)参数可以单个或者多个 ,当为单个时: findbyIds(List<Long> ids),或者findByids(Long [] ids) <se ...
- vue 2.0 无法编译ES6语法
# vue2.0 webpack 无法编译 ES6 语法 之前在使用 vue 1.x 时用 vue-loader@8.0.0 版本可以正常打包vue的代码,包括ES6语法也能正常转为ES5语法,但是当 ...
- Java learning notes (1):Basic Knowlege points
Basic Knowlege points: 1: it's necessary that there is only one public class in per .java file 2: .j ...
- jquery 自动触发事件 trigger
trigger() 栗子: 需求:我们在做二级联动的时候往往会遇到这样的需求,后台管理端页面加载完成后显示用户的省份,城市,并且可以对用户的省份,城市信息可以修改 如果只是简单的显示 你完全可以直接放 ...
- Foxit Reader(福昕PDF阅读器) v4.3.1.218 绿色专业版
软件名称:Foxit Reader(福昕PDF阅读器) v4.3.1.218 绿色专业版 软件语言: 简体中文 授权方式: 免费软件 运行环境: Win 32位/64位 软件大小: 4.40MB 图片 ...
- 【ARM】S3C6410芯片的启动流程
S3C6410芯片的启动流程 (1) 上电后首先运行iRom(BL0)内的代码,主要完成时钟和看门狗等外围器件的初始化.(2) 拷贝SD卡或者NnadFlash中的前4k(BL1)代码到片内ram(垫 ...
- XTU 1252 Defense Tower
$2016$长城信息杯中国大学生程序设计竞赛中南邀请赛$J$题 贪心. 优先删除$power$大的点. #pragma comment(linker, "/STACK:1024000000, ...
- hdu1034
#include<stdio.h>const int MAXN=1000;int a[MAXN];int main(){ int n; int i; while(scanf("% ...
- R语言数据结构
5. 数据结构 5.1 数据结构简介 (1)向量 一个向量的所有元素必须有相同的类型(模式) (2)列表 列表可以非同质的 列表可按位置索引:lst[[2]] 抽取子列表:lst[c(2,5)] 列表 ...
- java通过JDBC链接SQLServer2012 (含1433端口打通)
首先,在连接数据库之前必须保证SQL Server 2012是采用SQL Server身份验证方式而不是windows身份验证方式.如果在安装时选用了后者,则重新设置如下: http://blog.1 ...