QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#304577#8011. Instituteucup-team112#AC ✓133ms44508kbC++2011.9kb2024-01-13 21:17:552024-01-13 21:17:55

Judging History

你现在查看的是最新测评结果

  • [2024-01-13 21:17:55]
  • 评测
  • 测评结果:AC
  • 用时:133ms
  • 内存:44508kb
  • [2024-01-13 21:17:55]
  • 提交

answer


//#define _GLIBCXX_DEBUG

//#pragma GCC target("avx2")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
using namespace std;


#ifdef LOCAL
#include <debug_print.hpp>
#define OUT(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#define OUT(...) (static_cast<void>(0))
#endif

#define endl '\n'
#define lfs cout<<fixed<<setprecision(15)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define UNIQUE(a) (a).erase(unique((a).begin(),(a).end()),(a).end())
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using QP = priority_queue<T,vector<T>,greater<T>>;
template<typename T1, typename T2>bool chmin(T1 &a,T2 b){if(a>b){a=b;return true;}else return false;}
template<typename T1, typename T2>bool chmax(T1 &a,T2 b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T1,typename T2,typename T3>void anss(T1 x,T2 y,T3 z){ans(x!=y,x,z);};  
template<typename T>void debug(const T &v,ll h,ll w,string sv=" "){for(ll i=0;i<h;i++){cout<<v[i][0];for(ll j=1;j<w;j++)cout<<sv<<v[i][j];cout<<endl;}};
template<typename T>void debug(const T &v,ll n,string sv=" "){if(n!=0)cout<<v[0];for(ll i=1;i<n;i++)cout<<sv<<v[i];cout<<endl;};
template<typename T>void debug(const vector<T>&v){debug(v,v.size());}
template<typename T>void debug(const vector<vector<T>>&v){for(auto &vv:v)debug(vv,vv.size());}
template<typename T>void debug(stack<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(queue<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(deque<T> st){while(!st.empty()){cout<<st.front()<<" ";st.pop_front();}cout<<endl;}
template<typename T>void debug(PQ<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(QP<T> st){while(!st.empty()){cout<<st.top()<<" ";st.pop();}cout<<endl;}
template<typename T>void debug(const set<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
template<typename T>void debug(const multiset<T>&v){for(auto z:v)cout<<z<<" ";cout<<endl;}
template<typename T,size_t size>void debug(const array<T, size> &a){for(auto z:a)cout<<z<<" ";cout<<endl;}
template<typename T,typename V>void debug(const map<T,V>&v){for(auto z:v)cout<<"["<<z.first<<"]="<<z.second<<",";cout<<endl;}
template<typename T>vector<vector<T>>vec(ll x, ll y, T w){vector<vector<T>>v(x,vector<T>(y,w));return v;}
vector<ll>dx={1,-1,0,0,1,1,-1,-1};vector<ll>dy={0,0,1,-1,1,-1,1,-1};
template<typename T>vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v(ts...))>(a,make_v(ts...));}
template<typename T1, typename T2>ostream &operator<<(ostream &os, const pair<T1, T2>&p){return os << "(" << p.first << "," << p.second << ")";}
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v){os<<"[";for(auto &z:v)os << z << ",";os<<"]"; return os;}
template<typename T>void rearrange(vector<int>&ord, vector<T>&v){
  auto tmp = v;
  for(int i=0;i<tmp.size();i++)v[i] = tmp[ord[i]];
}
template<typename Head, typename... Tail>void rearrange(vector<int>&ord,Head&& head, Tail&&... tail){
  rearrange(ord, head);
  rearrange(ord, tail...);
}
template<typename T> vector<int> ascend(const vector<T>&v){
  vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
  sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],i)<make_pair(v[j],j);});
  return ord;
}
template<typename T> vector<int> descend(const vector<T>&v){
  vector<int>ord(v.size());iota(ord.begin(),ord.end(),0);
  sort(ord.begin(),ord.end(),[&](int i,int j){return make_pair(v[i],-i)>make_pair(v[j],-j);});
  return ord;
}
template<typename T> vector<T> inv_perm(const vector<T>&ord){
  vector<T>inv(ord.size());
  for(int i=0;i<ord.size();i++)inv[ord[i]] = i;
  return inv;
}
ll FLOOR(ll n,ll div){assert(div>0);return n>=0?n/div:(n-div+1)/div;}
ll CEIL(ll n,ll div){assert(div>0);return n>=0?(n+div-1)/div:n/div;}
ll digitsum(ll n){ll ret=0;while(n){ret+=n%10;n/=10;}return ret;}
ll modulo(ll n,ll d){return (n%d+d)%d;};
template<typename T>T min(const vector<T>&v){return *min_element(v.begin(),v.end());}
template<typename T>T max(const vector<T>&v){return *max_element(v.begin(),v.end());}
template<typename T>T acc(const vector<T>&v){return accumulate(v.begin(),v.end(),T(0));};
template<typename T>T reverse(const T &v){return T(v.rbegin(),v.rend());};
//mt19937 mt(chrono::steady_clock::now().time_since_epoch().count());
int popcount(ll x){return __builtin_popcountll(x);};
int poplow(ll x){return __builtin_ctzll(x);};
int pophigh(ll x){return 63 - __builtin_clzll(x);};
template<typename T>T poll(queue<T> &q){auto ret=q.front();q.pop();return ret;};
template<typename T>T poll(priority_queue<T> &q){auto ret=q.top();q.pop();return ret;};
template<typename T>T poll(QP<T> &q){auto ret=q.top();q.pop();return ret;};
template<typename T>T poll(stack<T> &s){auto ret=s.top();s.pop();return ret;};
ll MULT(ll x,ll y){if(LLONG_MAX/x<=y)return LLONG_MAX;return x*y;}
ll POW2(ll x, ll k){ll ret=1,mul=x;while(k){if(mul==LLONG_MAX)return LLONG_MAX;if(k&1)ret=MULT(ret,mul);mul=MULT(mul,mul);k>>=1;}return ret;}
ll POW(ll x, ll k){ll ret=1;for(int i=0;i<k;i++){if(LLONG_MAX/x<=ret)return LLONG_MAX;ret*=x;}return ret;}
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
  std::ostream::sentry s(dest);
  if (s) {
    __uint128_t tmp = value < 0 ? -value : value;
    char buffer[128];
    char *d = std::end(buffer);
    do {
      --d;
      *d = "0123456789"[tmp % 10];
      tmp /= 10;
    } while (tmp != 0);
    if (value < 0) {
      --d;
      *d = '-';
    }
    int len = std::end(buffer) - d;
    if (dest.rdbuf()->sputn(d, len) != len) {
      dest.setstate(std::ios_base::badbit);
    }
  }
  return dest;
}
namespace converter{
  int dict[500];
  const string lower="abcdefghijklmnopqrstuvwxyz";
  const string upper="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
  const string digit="0123456789";
  const string digit1="123456789";
  void regi_str(const string &t){
    for(int i=0;i<t.size();i++){
      dict[t[i]]=i;
    }
  }
  void regi_int(const string &t){
    for(int i=0;i<t.size();i++){
      dict[i]=t[i];
    }
  }
  vector<int>to_int(const string &s,const string &t){
    regi_str(t);
    vector<int>ret(s.size());
    for(int i=0;i<s.size();i++){
      ret[i]=dict[s[i]];
    }
    return ret;
  }
  vector<int>to_int(const string &s){
    auto t=s;
    sort(t.begin(),t.end());
    t.erase(unique(t.begin(),t.end()),t.end());
    return to_int(s,t);
  }
  
  vector<vector<int>>to_int(const vector<string>&s,const string &t){
    regi_str(t);
    vector<vector<int>>ret(s.size(),vector<int>(s[0].size()));
    for(int i=0;i<s.size();i++){
      for(int j=0;j<s[0].size();j++){
        ret[i][j]=dict[s[i][j]];
      }
    }
    return ret;
  }
  vector<vector<int>>to_int(const vector<string>&s){
    string t;
    for(int i=0;i<s.size();i++){
      t+=s[i];
    }
    sort(t.begin(),t.end());t.erase(unique(t.begin(),t.end()),t.end());
    return to_int(s,t);
  }
  string to_str(const vector<int>&s,const string &t){
    regi_int(t);
    string ret;
    for(auto z:s)ret+=dict[z];
    return ret;
  }
  vector<string> to_str(const vector<vector<int>>&s,const string &t){
    regi_int(t);
    vector<string>ret(s.size());
    for(int i=0;i<s.size();i++){
      for(auto z:s[i])ret[i]+=dict[z];
    }
    return ret;
  }
}
template< typename T = int >
struct edge {
  int to;
  T cost;
  int id;
  edge():to(-1),id(-1){};
  edge(int to, T cost = 1, int id = -1):to(to), cost(cost), id(id){}
  operator int() const { return to; }
};

template<typename T>
using Graph = vector<vector<edge<T>>>;
template<typename T>
Graph<T>revgraph(const Graph<T> &g){
  Graph<T>ret(g.size());
  for(int i=0;i<g.size();i++){
    for(auto e:g[i]){
      int to = e.to;
      e.to = i;
      ret[to].push_back(e);
    }
  }
  return ret;
}
template<typename T>
Graph<T> readGraph(int n,int m,int indexed=1,bool directed=false,bool weighted=false){
  Graph<T> ret(n);
  for(int es = 0; es < m; es++){
    int u,v;
    T w=1;
    cin>>u>>v;u-=indexed,v-=indexed;
    if(weighted)cin>>w;
    ret[u].emplace_back(v,w,es);
    if(!directed)ret[v].emplace_back(u,w,es);
  }
  return ret;
}
template<typename T>
Graph<T> readParent(int n,int indexed=1,bool directed=true){
  Graph<T>ret(n);
  for(int i=1;i<n;i++){
    int p;cin>>p;
    p-=indexed;
    ret[p].emplace_back(i);
    if(!directed)ret[i].emplace_back(p);
  }
  return ret;
}
template<typename T>
struct SCC{
  int n;
  const Graph<T>&G;
  vector<int>index;//各ノードが属する強連結成分の番号
  vector<int>start,visited,low,ord;
  int now_ord,group_num;
  SCC(const Graph<T> &g):G(g),n(g.size()){
    index.assign(n,-1);
    build();
  }
  void build(){
    low.assign(n,0);ord.assign(n,-1);index.assign(n,0);
    visited.reserve(n);
    now_ord=0,group_num=0;
    for(int i=0;i<n;i++){
      if(ord[i]==-1)dfs(i);
    }
    for(auto& x:index)x=group_num-1-x;
  }
  void dfs(int v){
    low[v]=ord[v]=now_ord++;
    visited.push_back(v);
    for(auto to:G[v]){
      if(ord[to]==-1){
        dfs(to);
        low[v]=min(low[v],low[to]);
      }
      else{
        low[v]=min(low[v],ord[to]);
      }
    }
    if(low[v]==ord[v]){
      while(1){
        int u=visited.back();
        visited.pop_back();
        ord[u]=n;
        index[u]=group_num;
        if(u==v)break;
      }
      group_num++;
    }

  }
  Graph<T>scc_graph;
  void build_edges(){
    scc_graph.resize(*max_element(index.begin(),index.end())+1);
    for(int i=0;i<n;i++){
      for(int j=0;j<G[i].size();j++){
        if(index[i]!=index[G[i][j]]){
          scc_graph[index[i]].emplace_back(index[G[i][j]], G[i][j].cost, G[i][j].id);
        }
      }
    }
  }
  vector<int>compsize(){
    vector<int>ret(*max_element(index.begin(),index.end())+1);
    for(int i=0;i<n;i++)ret[index[i]]++;
    return ret;
  }
  vector<int>output(){return index;};
};
template<typename G>
vector<ll> bfs(G &g,const vector<int>&s){
  vector<ll>dist(g.size(),INF);
  queue<int>que;
  int n=g.size();
  for(auto v:s){
    que.push(v);
    dist[v]=0;
  }
  while(!que.empty()){
    int x=que.front();
    que.pop();
    for(auto to:g[x]){
      if(dist[to]==INF){
        dist[to]=dist[x]+1;
        que.push(to);
      }
    }
  }
  return dist;
}
template<typename G>
vector<ll>bfs(G &g,int s=0){
  return bfs(g,vector<int>(1,s));
}
void solve(){
	ll res=0,buf=0;
  bool judge = true;
  ll n,m;cin>>n>>m;
  Graph<int>g1(n),g2(n);
  rep(i,0,m){
    ll u,v,t;cin>>u>>v>>t;u--;v--;
    if(t!=1)g2[u].EB(v);
    g1[u].EB(v);
  }
  auto d=bfs(g1,0);
  SCC scc(g2);
  scc.build_edges();
  bool sw=false;
  rep(i,0,n){
    if(d[i]!=INF&&scc.scc_graph[scc.index[i]].size()!=0){
      sw=true;
    }
  }
  ans1(sw);
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  int T = 1;
  //cin>>T;
  while(T--){
    solve();
  }
  return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3548kb

input:

3 4
1 2 1
2 3 2
3 2 1
3 1 2

output:

Yes

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 0ms
memory: 3560kb

input:

6 8
1 2 1
2 3 2
3 2 2
3 4 1
4 1 2
1 5 2
5 4 2
6 1 2

output:

No

result:

ok answer is NO

Test #3:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

1000 1000
141 466 1
634 659 1
179 96 2
445 344 2
993 974 1
310 114 2
32 333 1
758 832 1
834 1 1
874 825 2
480 61 2
765 100 2
804 616 1
496 545 1
786 261 2
899 263 1
962 237 2
766 807 1
561 583 1
35 425 1
201 291 1
6 142 1
61 386 2
785 861 2
386 986 2
288 769 2
850 209 1
660 259 2
258 143 2
646 715 2...

output:

Yes

result:

ok answer is YES

Test #4:

score: 0
Accepted
time: 1ms
memory: 3816kb

input:

1000 3000
719 279 2
857 23 1
984 625 2
904 509 2
892 456 2
589 195 2
718 932 2
608 363 1
474 672 1
217 993 2
165 895 2
727 329 2
932 404 2
952 146 2
201 272 2
412 895 2
228 267 2
396 365 2
813 794 2
259 250 1
968 764 2
100 76 2
924 665 2
981 931 2
292 975 2
903 649 2
793 101 2
54 703 1
853 58 2
356 ...

output:

Yes

result:

ok answer is YES

Test #5:

score: 0
Accepted
time: 1ms
memory: 4024kb

input:

1000 3000
686 470 2
132 418 2
775 962 2
814 8 2
450 767 2
580 243 2
742 534 2
508 304 2
396 513 2
731 385 2
499 309 2
144 150 2
111 209 2
340 189 1
219 755 2
511 655 2
428 941 2
165 707 2
253 619 2
140 766 2
999 132 2
415 101 2
887 192 2
598 262 2
312 675 1
97 527 2
407 179 2
11 154 1
107 996 2
586 ...

output:

No

result:

ok answer is NO

Test #6:

score: 0
Accepted
time: 3ms
memory: 4596kb

input:

10000 10000
1496 8533 1
6761 8802 2
3147 8733 2
7074 899 1
4191 9520 2
2576 1464 1
8600 116 2
72 5894 1
1605 6769 1
344 2583 2
9951 8053 2
2663 1396 1
3172 7307 1
8490 8085 2
6623 7814 2
680 4471 2
4906 3810 1
5952 8860 1
9670 3644 2
7993 6329 2
4666 1119 2
3115 3676 2
4506 2979 2
1451 2540 2
5002 9...

output:

No

result:

ok answer is NO

Test #7:

score: 0
Accepted
time: 3ms
memory: 5040kb

input:

10000 30000
8022 6065 2
8185 3186 1
9803 6371 1
4947 1271 2
926 9103 2
8367 1328 2
6314 1627 2
203 4366 2
9992 1021 2
5092 9288 1
7412 6217 2
4569 5568 2
7064 6970 2
4363 1581 2
772 6243 2
2571 4950 2
5821 8367 1
7985 5827 2
2064 4754 2
900 605 1
2083 3137 2
7852 1194 2
4679 6769 2
9389 6753 2
2980 ...

output:

Yes

result:

ok answer is YES

Test #8:

score: 0
Accepted
time: 7ms
memory: 5124kb

input:

10000 30000
6708 6418 2
120 3115 2
1647 6703 1
86 1015 2
5041 8379 2
1926 2108 2
1030 4579 2
1129 4269 2
7245 1725 2
9605 679 2
2903 1467 2
233 9636 2
8796 738 2
1535 7292 2
6010 1476 2
9300 4436 2
7465 5575 2
4508 1537 2
4352 9653 2
6646 4932 2
6069 2244 2
8361 4603 2
3566 9063 2
6836 5173 2
2194 3...

output:

No

result:

ok answer is NO

Test #9:

score: 0
Accepted
time: 108ms
memory: 44508kb

input:

300000 300000
94246 283175 1
83027 278500 2
265400 62933 2
174359 187478 2
175633 104311 1
279454 288119 1
143302 18555 1
258847 186237 1
207649 136874 1
182701 13491 1
261536 220848 1
206849 280776 2
60075 295 2
242474 256281 2
293852 21768 2
36248 183324 2
145642 275253 1
9956 11629 2
25110 265376...

output:

No

result:

ok answer is NO

Test #10:

score: 0
Accepted
time: 133ms
memory: 42100kb

input:

300000 300000
2755 160424 2
156539 216928 2
41979 111770 2
94794 284215 2
88031 115072 1
55508 189463 2
142066 99620 2
68946 262040 2
234053 268389 2
177636 61056 2
216374 97188 1
189152 250356 2
128748 241240 2
260431 9729 2
165046 99023 2
106219 190566 1
228664 97992 2
80967 18715 2
118443 178799 ...

output:

Yes

result:

ok answer is YES

Test #11:

score: 0
Accepted
time: 113ms
memory: 41708kb

input:

300000 300000
201841 218620 2
25571 244075 2
148023 244788 1
12618 187161 2
123903 157292 2
140719 283744 2
48104 57739 2
94140 217701 2
260292 235506 2
244136 52545 2
113842 82619 2
284670 286686 2
102210 172102 2
93693 135210 2
169155 31435 1
121590 294638 2
231463 149656 2
132100 245329 2
78578 2...

output:

No

result:

ok answer is NO

Test #12:

score: 0
Accepted
time: 50ms
memory: 13452kb

input:

10000 300000
8794 9638 2
4124 3198 2
3709 4571 1
7094 2604 2
9787 8634 1
9259 7034 1
805 8951 1
523 1299 2
4067 2337 1
3442 8604 1
990 229 2
5669 9222 2
794 5188 2
7066 4135 1
2328 6841 2
5400 3669 2
8572 6053 2
5808 755 2
1035 9229 2
4699 4976 1
5592 6836 2
3316 5324 1
911 8988 1
6872 3245 2
1266 1...

output:

No

result:

ok answer is NO

Test #13:

score: 0
Accepted
time: 101ms
memory: 32520kb

input:

200000 300000
51429 85416 2
35500 102166 2
77261 111280 2
109595 198771 2
52752 98485 2
123959 146471 1
71558 134628 2
53580 97704 2
41770 26184 2
38726 42080 2
32420 161261 1
93622 14014 2
62442 37971 2
97434 174665 2
35402 17953 2
32481 189105 2
133381 197488 2
59630 152080 2
145316 134738 2
15637...

output:

Yes

result:

ok answer is YES

Test #14:

score: 0
Accepted
time: 97ms
memory: 32676kb

input:

200000 300000
100604 79567 2
78619 82912 2
160923 6515 2
111511 22849 2
191823 122510 2
184746 42969 1
367 87329 2
12385 186721 2
22322 89968 2
30296 23410 2
55379 95908 2
78731 185005 2
16026 95076 2
117553 81021 2
17586 162896 2
112457 64630 2
98272 194597 2
94737 47348 2
182434 141187 2
48901 148...

output:

No

result:

ok answer is NO

Test #15:

score: 0
Accepted
time: 90ms
memory: 21812kb

input:

100000 300000
60010 76924 2
98779 52066 2
29705 3673 2
19807 92766 2
89092 55572 2
57798 98074 2
49433 4252 2
9568 11858 2
6068 37755 2
42537 69332 2
34120 95829 2
70957 69524 1
6979 42493 2
18708 80499 2
23615 10086 1
54682 14663 2
66240 6913 1
96259 63852 2
33994 20136 2
50051 79458 2
59557 23910 ...

output:

Yes

result:

ok answer is YES

Test #16:

score: 0
Accepted
time: 103ms
memory: 21900kb

input:

100000 300000
31467 31057 2
53376 30862 2
34548 19018 1
49459 40636 2
24713 26389 2
72031 39008 2
88386 42964 2
6089 36050 2
95525 7354 2
2150 65839 2
23017 48586 2
96644 53330 1
34717 92329 2
60439 23051 2
93738 40918 2
14792 19952 2
47044 31402 2
50447 82391 2
39716 49649 2
53032 32891 1
21843 227...

output:

No

result:

ok answer is NO

Test #17:

score: 0
Accepted
time: 61ms
memory: 15824kb

input:

50000 300000
13657 42151 1
4207 48263 2
19913 14856 1
20252 19946 1
36552 16773 2
15641 47894 1
31929 33862 1
37186 35146 1
26141 19435 1
13344 16689 1
40537 30282 1
44007 12832 2
34199 4971 2
9613 32152 1
22680 7733 1
22821 37016 1
28192 6124 2
20231 20606 2
31231 11050 1
29171 1156 2
10913 10822 2...

output:

Yes

result:

ok answer is YES

Test #18:

score: 0
Accepted
time: 74ms
memory: 15888kb

input:

50000 300000
27901 2832 1
36611 18040 1
11569 29790 1
18772 5119 1
7295 20713 2
34886 41675 1
25208 25186 2
16871 28421 1
16342 25825 1
45452 6926 1
19333 47812 1
49794 31792 2
47593 29029 1
28847 13670 2
10893 34216 2
38904 38242 1
20662 21579 1
39456 43904 2
10339 35210 1
28253 11494 2
22 12016 2
...

output:

No

result:

ok answer is NO

Test #19:

score: 0
Accepted
time: 59ms
memory: 12860kb

input:

25000 300000
15694 6658 1
12187 18447 1
7540 10018 2
6657 5485 1
21747 711 1
12141 9379 1
21107 3608 1
2289 12866 1
23634 21695 2
19657 17685 2
7651 7593 1
14284 17908 1
7629 9649 1
6823 23485 1
534 24307 2
22109 6259 1
21590 6443 2
22852 13772 1
6668 21394 1
11103 4709 1
13738 22004 2
1428 11491 1
...

output:

Yes

result:

ok answer is YES

Test #20:

score: 0
Accepted
time: 60ms
memory: 12952kb

input:

25000 300000
20441 13493 1
362 263 1
2835 1312 1
22325 18409 1
4902 3889 1
11908 10885 2
20159 19508 1
22897 21371 1
803 24842 1
15205 19941 1
1454 20196 2
24937 1426 1
7432 16934 1
2006 12538 1
14316 17932 1
10790 1834 1
142 19649 2
3390 22164 2
14482 11138 1
24265 21337 1
16629 20993 1
14448 23824...

output:

No

result:

ok answer is NO

Test #21:

score: 0
Accepted
time: 41ms
memory: 35424kb

input:

200000 299998
1 2 1
1 3 1
3 2 2
1 4 1
4 2 2
1 5 1
5 2 2
1 6 1
6 2 2
1 7 1
7 2 2
1 8 1
8 2 2
1 9 1
9 2 2
1 10 1
10 2 2
1 11 1
11 2 2
1 12 1
12 2 2
1 13 1
13 2 2
1 14 1
14 2 2
1 15 1
15 2 2
1 16 1
16 2 2
1 17 1
17 2 2
1 18 1
18 2 2
1 19 1
19 2 2
1 20 1
20 2 2
1 21 1
21 2 2
1 22 1
22 2 2
1 23 1
23 2 2
...

output:

Yes

result:

ok answer is YES

Extra Test:

score: 0
Extra Test Passed