#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. 回家(洛谷 P1592)

    模板题.. 传送门:codevs 1079 思路 :以 Z 为起点 直接跑一边SPFA , 看哪一头母牛距离Z点最近 , 最后找出Z 到 A~Y 的最短路 (因为仅有A~Z有奶牛) #include ...

  2. 【LeetCode】25. Reverse Nodes in k-Group

    Given a linked list, reverse the nodes of a linked list k at a time and return its modified list. k  ...

  3. nio简介

    上一篇  Java I/O演进与Linux网络I/O模型 一.传统BIO java传统bio编程概念: http://www.cnblogs.com/carl10086/p/6034563.html# ...

  4. 如何运用xp_cmdshell 执行多行cmd命令

    因为需要利用sql  脚本调用外部程序,所以尝试xp_cmdshell 命令,发现其默认只能执行一行命令,最后找到了下面方法: 将多行cmd 命令处理成bat文件,然后直接利用所在路径+文件来执行: ...

  5. c# 读取ACCESS 数据库

    using System; using System.Collections.Generic; using System.Data.OleDb; using System.IO; using Syst ...

  6. 记录下 js各种证件的正则验证

    身份证 /(^\d{15}$)|(^\d{17}([0-9]|X)$)/    护照 /^[a-zA-Z0-9]{3,21}$/   /^(P\d{7})|(G\d{8})$/    军官证或士兵证 ...

  7. 升级ruby

    1.安装 RVM RVM:Ruby Version Manager,Ruby版本管理器,包括Ruby的版本管理和Gem库管理(gemset) $ curl -L get.rvm.io | bash - ...

  8. PHP strtotime在linux服务器时间延迟8小时问题

    今天客户反映有个功能投票模块第一天投了后,第二天就不能投了,理论上是第二天凌晨就可以再答题的,发现本地是正常的,linux服务器异常, 仔细查找原因发现是strtotime函数获取的值和本地获取的值不 ...

  9. 如何使用Git上传代码到GitHub

    1.在Github上面创建Github仓库: 2.下载Github Shell到本地:https://desktop.github.com/ 3.打开Github Shell,输入以下命令生成秘钥来验 ...

  10. Qt出现常量有换行符的错误的解决方法

    可以使用 QString::fromLocal8Bit 来将本地字符编码转换为 Unicode 形式的 QString.