#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的更多相关文章

  1. csu oj 1339: 最后一滴血

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1339 1339: 最后一滴血 Time Limit: 1 Sec  Memory Limit: 1 ...

  2. csu oj 1330 字符识别?

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1330 1330: 字符识别? Time Limit: 1 Sec  Memory Limit: 1 ...

  3. csu oj 1811: Tree Intersection (启发式合并)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1811 给你一棵树,每个节点有一个颜色.问删除一条边形成两棵子树,两棵子树有多少种颜色是有 ...

  4. csu oj 1804: 有向无环图 (dfs回溯)

    题目链接:http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1804 中文题意就不说了. dfs从底到根回溯即可,看代码应该能清楚. //#pragma ...

  5. csu oj 1344: Special Judge

    Description Given a positive integer n, find two non-negative integers a, b such that a2 + b2 = n. I ...

  6. csu oj 1343 Long Long

    Description 现在有两个单调递增序列,第一个序列有N个整数,第二个序列有M个整数,现在你可以从第一个序列中选一个数x,然后从第二个序列中选一个数y,那么有多少种情况满足x+y<=K呢? ...

  7. csu oj 1341 string and arrays

    Description 有一个N*N的字符矩阵,从上到下依次记为第1行,第2行,……,第N行,从左至右依次记为第1列,第2列,……,第N列. 对于这个矩阵会进行一系列操作,但这些操作只有两类: (1) ...

  8. 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 ...

  9. CSU OJ PID=1514: Packs 超大背包问题,折半枚举+二分查找。

    1514: Packs Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 61  Solved: 4[Submit][Status][Web Board] ...

随机推荐

  1. Android设备标识符的使用

    设备ID(DeviceId) 获取办法 android.telephony.TelephonyManager tm = (android.telephony.TelephonyManager) con ...

  2. STM32 Keil查看程序占用ROM和RAM

    1. 编译生成的map文件中code , RO ,RW, ZI 表示内容 Code为程序代码部分 RO-data 表示 程序定义的常量const temp; RW-data 表示 已初始化的全局变量 ...

  3. Genymotion下载失败解决方法

    Genymotion下载虚拟机版本时会很慢,而且经常下载失败 解决方法如下: 1.先去选择下载你需要的版本,之后会下载(很慢),或者失败. 2.到C:\Users\yourname\AppData\L ...

  4. JS 高效快速的数组去重

    Array.prototype.uniquer = function() { var result = [], hash = {}; ; i < this.length; i++) { if ( ...

  5. 视频和字幕演示APK, 欢迎下载

    视频和字幕合成的演示APK 移动视频处理, 小咖秀-美拍-秒拍需要的字幕合成功能 我们推出这个demo, 视频格式支持MP4,字幕支持SRT/ASS/LRC,字幕文件编码为UTF8格式. 欢迎定制视频 ...

  6. PHP设置session多级路径并定期自动清理

    一.修改 php.ini 配置 vi /usr/local/php/etc/php.ini 1.路径和目录深度: session.save_path = "3;/tmp/session&qu ...

  7. java web开发环境搭建:jdk1.8+eclipse+tomcat8.0

    一.安装JDK 1.下载jdk-8-windows-i586.exe 2.双击安装(可以将安装路径选择到自己喜欢的地方) 3.配置环境变量 1.我的电脑->2.右键单击-> 然后将%JAV ...

  8. 一步步优化JVM二:JVM部署模型和JVM Runtime

    选择JVM部署模型    JVM部署模型的选择总体来说就是决定应用是部署在单个JVM实例还是多个JVM实例上(这里简单举例说明一下JVM实例,比如:我们常用eclipse开发,启动一个eclipse就 ...

  9. LeetCode 319. Bulb Switcher

    There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every ...

  10. A* 寻路算法学习

    代码小记 #include <iostream> #include <list> struct POINT { int X; int Y; }; // G: 起点到当前点的成本 ...