#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. C# CookieHelper

    using System; using System.Web; using System.Collections.Specialized; namespace Utils { /// <summ ...

  2. ASP.NET Core: Getting Started with ASP.NET MVC Core

    1. ASP.NET Core the Unified Framework ASP.NET Core的统一框架 2. New Solution Project 新的解决方案项目 src folder: ...

  3. LoadLibraryW 参数问题

    error C2664: "LoadLibraryW": 不能将参数1 从"const char [8]"转换为"LPCWSTR" 右击工程 ...

  4. SVN版本控制的使用

    下面说一说本人对SVN工具使用的理解: SVN就是一个工具,一个用来便于多人(或说团队)开发代码的版本控制工具,我们可以用它很好的把多个程序员开发出来的代码统一起来,并且保证在这个工程中不出现任何差错 ...

  5. Linux中一些简单命令(一)

    1.查看当前用户:who 2.显示当前目录:pwd 3.查看当前服务器的时间:date 4.查看日历:cal+year; 例如:cal 2016 5.计算器:bc  退出计算器:quit或者ctrl+ ...

  6. Mammoth官方文档翻译

    用于.NET的.docx转HTML的Mammoth Mammoth可用于将.docx文档(比如由Microsoft Word创建的)转换为HTML.Mammoth致力于通过文档中的语义信息生成简洁的H ...

  7. 【锋利的Jquery】读书笔记二

    一.jquery选择器 基本选择器 层次选择器 过滤选择器 基本过滤 内容过滤 可见性过滤 属性过滤 子元素过滤 first  : 获取单个元素       $("div:first&quo ...

  8. 修改LibreOffice Draw中定义的样式名称

    目前我使用的是LibreOffice 4.2.4.2.经过以往的测试和使用经验,这是诸多版本中较为稳定和bug相对较少的.今天无意中发现该版本的LibreOffice Draw存在一个问题:样式名称修 ...

  9. ie Css Hack 特殊符号

    Css Hack 特殊符号 (1)* :IE6/7都能识别*,标准浏览器不识别(2)_:只有IE6识别(3)!Important:IE6不识别,Firefox,IE7/8/9.chorme等主流浏览器 ...

  10. SQLServer 重建索引前后对比

    在做维护项目的时,我们经常会遇到索引维护的问题,通过语句,我们就可以判断某个表的索引是否需要重建. 执行一下语句:先分析表的索引 分析表的索引建立情况:DBCC showcontig('Table') ...