Language: C++

#include<iostream>
#include<vector>
#include<set>
using namespace std;
#define df 0

struct edge{
  int u;
  int v;

  edge(int a,int b){ u=a;v=b;}
};

int find(int v,vector<int>& uf){
  if(uf.at(v)<0)return v;
  return (uf.at(v)=find(uf.at(v),uf));
}

void merge(int u,int v,vecor<int>& uf){
  u=find(u,uf);v=find(v,vf);
  if(u==v)return;
  if(uf.at(u)>uf.at(v)) swap(u,v);
  uf.at(v)=uf.at(u);
  uf.at(u)--;
}

int main(){
  if(df) printf("*debug mode*\n");
  int n,m,q; cin >>n >>m >>q;
  vector<edge> a(q);
  vector<int> uf(n,-1);
  for(int i=0;i<q;i++){
    int u,v;
    int flag; cin >>u >>v >>flag;
    if(flag){
      marge(u,v);
    }
    else a.push_back(edge{u,v});
  }
  int flag=1;
  for(edge e: a){
    if(find(e.u,uf)==find(e.v,uf))flag=0;
  }
  set<int>s;
  for(int i=0;i<n;i++){
    s.insert(find(i,uf));
  }
  long int num=s.count();
  num=num*(num-1)/2-(num-1);
  num+=n;
  if(num<m)flag=0;
  if(flag)cout<<"Yes";
  else cout<<"No";
}

/// confirm df==0 ///


Compiler output:
a.cc:19:24: error: 'vecor' has not been declared
   19 | void merge(int u,int v,vecor<int>& uf){
      |                        ^~~~~
a.cc:19:29: error: expected ',' or '...' before '<' token
   19 | void merge(int u,int v,vecor<int>& uf){
      |                             ^
a.cc: In function 'void merge(int, int, int)':
a.cc:20:12: error: 'uf' was not declared in this scope; did you mean 'u'?
   20 |   u=find(u,uf);v=find(v,vf);
      |            ^~
      |            u
a.cc:20:25: error: 'vf' was not declared in this scope; did you mean 'v'?
   20 |   u=find(u,uf);v=find(v,vf);
      |                         ^~
      |                         v
a.cc: In function 'int main()':
a.cc:36:7: error: 'marge' was not declared in this scope; did you mean 'merge'?
   36 |       marge(u,v);
      |       ^~~~~
      |       merge
a.cc:48:23: error: no matching function for call to 'std::set<int>::count()'
   48 |   long int num=s.count();
      |                ~~~~~~~^~
In file included from /usr/include/c++/14/set:63,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_set.h:756:9: note: candidate: 'template<class _Kt> decltype (((const std::set<_Key, _Compare, _Alloc>*)this)->std::set<_Key, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::set<_Key, _Compare, _Alloc>::count(const _Kt&) const [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  756 |         count(const _Kt& __x) const
      |         ^~~~~
/usr/include/c++/14/bits/stl_set.h:756:9: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_set.h:750:7: note: candidate: 'std::set<_Key, _Compare, _Alloc>::size_type std::set<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; size_type = long unsigned int; key_type = int]'
  750 |       count(const key_type& __x) const
      |       ^~~~~
/usr/include/c++/14/bits/stl_set.h:750:7: note:   candidate expects 1 argument, 0 provided
In file included from /usr/include/c++/14/bits/alloc_traits.h:33,
                 from /usr/include/c++/14/ext/alloc_traits.h:34,
                 from /usr/include/c++/14/bits/basic_string.h:39,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_construct.h: In instantiation of 'void std::_Construct(_Tp*, _Args&& ...) [with _Tp = edge; _Args = {}]':
/usr/include/c++/14/bits/stl_uninitialized.h:643:18:   required from 'static _ForwardIterator std::__uninitialized_default_n_1<_TrivialValueType>::__uninit_default_n(_ForwardIterator, _Size) [with _ForwardIterator = edge*; _Size = long unsigned int; bool _TrivialValueType = false]'
  643 |                 std::_Construct(std::__addressof(*__cur));
      |                 ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:712:20:   required from '_ForwardIterator std::__uninitialized_default_n(_ForwardIterator, _Size) [with _ForwardIterator = edge*; _Size = long unsigned int]'
  710 |       return __uninitialized_default_n_1<__is_trivial(_ValueType)
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  711 |                                          && __can_fill>::
      |                                          ~~~~~~~~~~~~~~~~
  712 |         __uninit_default_n(__first, __n);
      |         ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_uninitialized.h:779:44:   required from '_ForwardIterator std::__uninitialized_default_n_a(_ForwardIterator, _Size, allocator<_Tp>&) [with _ForwardIterator = edge*; _Size = long unsigned int; _Tp = edge]'
  779 |     { return std::__uninitialized_default_n(__first, __n); }
      |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1720:36:   required from 'void std::vector<_Tp, _Alloc>::_M_default_initialize(size_type) [with _Tp = edge; _Alloc = std::allocator<edge>; size_type = long unsigned int]'
 1720 |           std::__uninitialized_default_n_a(this->_M_impl._M_start, __n,
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1721 |                                            _M_get_Tp_allocator());
      |                                            ~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:558:9:   required from 'std::vector<_Tp, _Alloc>::vector(size_type, const allocator_type&) [with _Tp = edge; _Alloc = std::allocator<edge>; size_type = long unsigned int; allocator_type = std::allocator<edge>]'
  558 |       { _M_default_initialize(__n); }
      |         ^~~~~~~~~~~~~~~~~~~~~
a.cc:30:19:   required from here
   30 |   vector<edge> a(q);
      |                   ^
/usr/include/c++/14/bits/stl_construct.h:119:7: error: no matching function for call to 'edge::edge()'
  119 |       ::new((void*)__p) _Tp(std::forward<_Args>(__args)...);
      |       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:11:3: note: candidate: 'edge::edge(int, int)'
   11 |   edge(int a,int b){ u=a;v=b;}
      |   ^~~~
a.cc:11:3: note:   candidate expects 2 arguments, 0 provided
a.cc:7:8: note: candidate: 'constexpr edge::edge(const edge&)'
    7 | struct edge{
      |        ^~~~
a.cc:7:8: note:   candidate expects 1 argument, 0 provided
a.cc:7:8: note: candidate: 'constexpr edge::edge(edge&&)'
a.cc:7:8: note:   candidate expects 1 argument, 0 provided