1#include <iostream>2#include <algorithm>3#include <stdio.h>4 #defineMax 200055 #definell Long Long6 using namespacestd;7 8 structg{9 int from;Ten intto ; One ll time; A }game[max]; - - BOOLGraf[max]; the - BOOLCMP (G a,g b) { - returnA.time <B.time; - } + intMain () - { + intn,m; A while(cin>>n>>L) { at for(inti =0; I < max;i++){ -graf[i]=false; -Game[i].time=game[i]. from=game[i].to=0; - } -graf[1]=true; - in for(inti =0; I < m;i++){ -Cin>>game[i].time>>game[i]. from>>game[i].to; to } +Sort (game,game+m,cmp); - the BOOLFlag =false; * for(inti =0; I < m;i++){ $ if(Game[i]. from==1){Panax NotoginsengFlag =true; - //graf[game[i].to] = true; the } + if(Flag&&graf[game[i]. from]){ AGraf[game[i].to] =true; the } + } -ll ans =0; $ for(inti =1; I <= n;i++){ $ if(Graf[i]) ans++; - } -cout<<ans<<Endl; the } - return 0;Wuyi}
If I have to divide it, I think it belongs to and look up a kind of
CSU OJ infected computer 1427