#include using namespace std; map mapp; struct Edge{ int to; double cost; }; vector v[20001]; int fl[20001]; bool ANS = false; void Rec(int k, double tek) { if(fl[k] == 2) return; if(fl[k] == 1) { if(tek > 1) ANS = true; return; } fl[k] = 1; for(int i=0;i>s1>>s2; scanf("%lf", &cost); if(mapp[s1] == 0) mapp[s1] = ++pos; if(mapp[s2] == 0) mapp[s2] = ++pos; v[mapp[s1]].push_back({mapp[s2], cost}); } for(i=1;i<=pos;i++) { fill(fl, fl+pos+1, 0); Rec(i, 1); if(ANS) break; } if(ANS) { printf("YES\n"); return 0; } for(i=1;i<=pos;i++) reverse(v[i].begin(), v[i].end()); for(i=1;i<=pos;i++) { fill(fl, fl+pos+1, 0); Rec(i, 1); if(ANS) break; } if(ANS) printf("YES\n"); else printf("NO\n"); return 0; } /* 6 1 2 0.99 2 3 0.5 3 2 0.1 3 1 1.1 2 4 1.2 4 3 0.9 */