Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

struct Pair{
  int a;
  int b;
};

int dig(int a){
  int ans=1;
  for(int i=0; i<a; i++){
    ans*= 10;
  }
  return ans;
}

int main(){
  int n,m,s,c,max,ans;
  cin >> n >> m;
  vector<Pair> sc(m);
  rep(i,0,m){
    cin >> s >> c;
    sc[i].a= s;
    sc[i].b= c;
  }

  max=dig(n);
  for(int i=0; i<max+1; i++){
    for(int j=0; j<m; j++){
      if((string)i[sc[j].a-1]==(string)sc[j].b){
        ans=i;
      }
    }
    if(i==max)  ans=-1;
  }
  cout << ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:19: error: invalid types 'int[int]' for array subscript
   40 |       if((string)i[sc[j].a-1]==(string)sc[j].b){
      |                   ^
a.cc:40:46: error: no matching function for call to 'std::__cxx11::basic_string<char>::basic_string(int&)'
   40 |       if((string)i[sc[j].a-1]==(string)sc[j].b){
      |                                              ^
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:800:9: note: candidate: 'template<class _Tp, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Tp&, const _Alloc&) [with <template-parameter-2-2> = _Tp; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  800 |         basic_string(const _Tp& __t, const _Alloc& __a = _Alloc())
      |         ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:800:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/type_traits: In substitution of 'template<bool _Cond, class _Tp> using std::enable_if_t = typename std::enable_if::type [with bool _Cond = false; _Tp = void]':
/usr/include/c++/14/bits/basic_string.h:149:8:   required by substitution of 'template<class _CharT, class _Traits, class _Alloc> template<class _Tp, class _Res> using std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::_If_sv = std::enable_if_t<((bool)std::__and_<std::is_convertible<const _Tp&, std::basic_string_view<_CharT, _Traits> >, std::__not_<std::is_convertible<const _Tp*, const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>*> >, std::__not_<std::is_convertible<const _Tp&, const _CharT*> > >::value), _Res> [with _Tp = int; _Res = void; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  149 |         using _If_sv = enable_if_t<
      |               ^~~~~~
/usr/include/c++/14/bits/basic_string.h:797:30:   required from here
  797 |       template<typename _Tp, typename = _If_sv<_Tp, void>>
      |                              ^~~~~~~~
/usr/include/c++/14/type_traits:2711:11: error: no type named 'type' in 'struct std::enable_if<false, void>'
 2711 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:788:9: note: candidate: 'template<class _Tp, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Tp&, size_type, size_type, const _Alloc&) [with <template-parameter-2-2> = _Tp; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  788 |         basic_string(const _Tp& __t, size_type __pos, size_type __n,
      |         ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:788:9: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:765:9: note: candidate: 'template<class _InputIterator, class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(_InputIterator, _InputIterator, const _Alloc&) [with <template-parameter-2-2> = _InputIterator; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  765 |         basic_string(_InputIterator __beg, _InputIterator __end,
      |         ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:765:9: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:669:7: note: candidate: 'template<class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(size_type, _CharT, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  669 |       basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
      |       ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:669:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:646:7: note: candidate: 'template<class> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  646 |       basic_string(const _CharT* __s, const _Alloc& __a = _Alloc())
      |       ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:646:7: note:   template argument deduction/substitution failed:
a.cc:40:46: note:   cannot convert 'sc.std::vector<Pair>::operator[](((std::vector<Pair>::size_type)j)).Pair::b' (type 'int') to type 'const char*'
   40 |       if((string)i[sc[j].a-1]==(string)sc[j].b){
/usr/include/c++/14/bits/basic_string.h:721:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  721 |       basic_string(basic_string&& __str, const _Alloc& __a)
      |       ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:721:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:716:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  716 |       basic_string(const basic_string& __str, const _Alloc& __a)
      |       ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:716:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:711:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::initializer_list<_Tp>, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  711 |       basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc())
      |       ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:711:45: note:   no known conversion for argument 1 from 'int' to 'std::initializer_list<char>'
  711 |       basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc())
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:682:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  682 |       basic_string(basic_string&& __str) noexcept
      |       ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:682:35: note:   no known conversion for argument 1 from 'int' to 'std::__cxx11::basic_string<char>&&'
  682 |       basic_string(basic_string&& __str) noexcept
      |                    ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:624:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
  624 |       basic_string(const _CharT* __s, size_type __n,
      |       ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:624:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:604:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
  604 |       basic_string(const basic_string& __str, size_type __pos,
      |       ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:604:7: note:   candidate expects 4 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:586:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
  586 |       basic_string(const basic_string& __str, size_type __pos,
      |       ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:586:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:569:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&, size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
  569 |       basic_string(const basic_string& __str, size_type __pos,
      |       ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:569:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:552:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  552 |       basic_string(const basic_string& __str)
      |       ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:552:40: note:   no known conversion for argument 1 from 'int' to 'const std::__cxx11::basic_string<char>&'
  552 |       basic_string(const basic_string& __str)
      |                    ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:540:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  540 |       basic_string(const _Alloc& __a) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:540:34: note:   no known conversion for argument 1 from 'int' to 'cons