Submission #1293833

#TimeUsernameProblemLanguageResultExecution timeMemory
1293833eldaees131313Match (CEOI16_match)C++20
Compilation error
0 ms0 KiB
////////////////////////////// Author:eldaee, coder_viper!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!11
#pragma GCC optimize ("Ofast")
#include <bits/stdc++.h>
#define int long long
#define str string
#define vec vector
#define dou double
#define ld long double
#define pb push_back
#define ppb pop_back
#define eb emplace_back
#define YES cout << "YES" << '\n'
#define Yes cout << "Yes" << '\n'
#define NO cout << "NO" << '\n'
#define No cout << "No" << '\n'
#define gcd __gcd
#define all(x) x.begin(),x.end()
#define eldaee ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

void solve() {
    str s;
    cin >> s;
    int n = (int) s.size();
    str res(n);
    int x[26];
    for (int i = 0; i < n; i++) {
        x[i] = -1;
    }
    int y = 0;
    int i = 0;
    for (chat ch : s) {
        int pos = ch - 'a';
        if (x[pos] == -1) {
            res[i] = '(';
            x[pos] = i;
            y++;
        }
        else {
            res[i] = ')';
            x[pos] - 1;
            y--;
            if (y < 0) {
                cout << -1 << '\n';
                return 0;
            }
        }
        i++;
    }
    if (y != 0) {
        cout << -1 << '\n';
        return 0;
    }
    cout << res << '\n';
}

signed main()
{
    eldaee
    
    solve();
}

Compilation message (stderr)

match.cpp: In function 'void solve()':
match.cpp:25:14: error: no matching function for call to 'std::__cxx11::basic_string<char>::basic_string(long long int&)'
   25 |     str res(n);
      |              ^
In file included from /usr/include/c++/13/string:54,
                 from /usr/include/c++/13/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:52,
                 from match.cpp:3:
/usr/include/c++/13/bits/basic_string.h:795:9: note: candidate: 'template<class _Tp, class> constexpr 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>]'
  795 |         basic_string(const _Tp& __t, const _Alloc& __a = _Alloc())
      |         ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:795:9: note:   template argument deduction/substitution failed:
In file included from /usr/include/c++/13/bits/stl_pair.h:60,
                 from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51:
/usr/include/c++/13/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++/13/bits/basic_string.h:144: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<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 = long long int; _Res = void; _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
/usr/include/c++/13/bits/basic_string.h:792:30:   required from here
/usr/include/c++/13/type_traits:2610:11: error: no type named 'type' in 'struct std::enable_if<false, void>'
 2610 |     using enable_if_t = typename enable_if<_Cond, _Tp>::type;
      |           ^~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:783:9: note: candidate: 'template<class _Tp, class> constexpr 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>]'
  783 |         basic_string(const _Tp& __t, size_type __pos, size_type __n,
      |         ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:783:9: note:   template argument deduction/substitution failed:
match.cpp:25:14: note:   candidate expects 4 arguments, 1 provided
   25 |     str res(n);
      |              ^
/usr/include/c++/13/bits/basic_string.h:760:9: note: candidate: 'template<class _InputIterator, class> constexpr 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>]'
  760 |         basic_string(_InputIterator __beg, _InputIterator __end,
      |         ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:760:9: note:   template argument deduction/substitution failed:
match.cpp:25:14: note:   candidate expects 3 arguments, 1 provided
   25 |     str res(n);
      |              ^
/usr/include/c++/13/bits/basic_string.h:664:7: note: candidate: 'template<class> constexpr 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>]'
  664 |       basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc())
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:664:7: note:   template argument deduction/substitution failed:
match.cpp:25:14: note:   candidate expects 3 arguments, 1 provided
   25 |     str res(n);
      |              ^
/usr/include/c++/13/bits/basic_string.h:641:7: note: candidate: 'template<class> constexpr 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>]'
  641 |       basic_string(const _CharT* __s, const _Alloc& __a = _Alloc())
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:641:7: note:   template argument deduction/substitution failed:
match.cpp:25:13: note:   cannot convert 'n' (type 'long long int') to type 'const char*'
   25 |     str res(n);
      |             ^
/usr/include/c++/13/bits/basic_string.h:716:7: note: candidate: 'constexpr 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>]'
  716 |       basic_string(basic_string&& __str, const _Alloc& __a)
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:716:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/13/bits/basic_string.h:711:7: note: candidate: 'constexpr 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>]'
  711 |       basic_string(const basic_string& __str, const _Alloc& __a)
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:711:7: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/13/bits/basic_string.h:706:7: note: candidate: 'constexpr 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>]'
  706 |       basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc())
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:706:45: note:   no known conversion for argument 1 from 'long long int' to 'std::initializer_list<char>'
  706 |       basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc())
      |                    ~~~~~~~~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/basic_string.h:677:7: note: candidate: 'constexpr 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>]'
  677 |       basic_string(basic_string&& __str) noexcept
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:677:35: note:   no known conversion for argument 1 from 'long long int' to 'std::__cxx11::basic_string<char>&&'
  677 |       basic_string(basic_string&& __str) noexcept
      |                    ~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/13/bits/basic_string.h:619:7: note: candidate: 'constexpr 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]'
  619 |       basic_string(const _CharT* __s, size_type __n,
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:619:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/13/bits/basic_string.h:599:7: note: candidate: 'constexpr 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]'
  599 |       basic_string(const basic_string& __str, size_type __pos,
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:599:7: note:   candidate expects 4 arguments, 1 provided
/usr/include/c++/13/bits/basic_string.h:581:7: note: candidate: 'constexpr 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]'
  581 |       basic_string(const basic_string& __str, size_type __pos,
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:581:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/13/bits/basic_string.h:564:7: note: candidate: 'constexpr 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]'
  564 |       basic_string(const basic_string& __str, size_type __pos,
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:564:7: note:   candidate expects 3 arguments, 1 provided
/usr/include/c++/13/bits/basic_string.h:547:7: note: candidate: 'constexpr 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>]'
  547 |       basic_string(const basic_string& __str)
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:547:40: note:   no known conversion for argument 1 from 'long long int' to 'const std::__cxx11::basic_string<char>&'
  547 |       basic_string(const basic_string& __str)
      |                    ~~~~~~~~~~~~~~~~~~~~^~~~~
/usr/include/c++/13/bits/basic_string.h:535:7: note: candidate: 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  535 |       basic_string(const _Alloc& __a) _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:535:34: note:   no known conversion for argument 1 from 'long long int' to 'const std::allocator<char>&'
  535 |       basic_string(const _Alloc& __a) _GLIBCXX_NOEXCEPT
      |                    ~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/basic_string.h:522:7: note: candidate: 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  522 |       basic_string()
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:522:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/13/bits/basic_string.h:176:7: note: candidate: 'constexpr std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::basic_string(__sv_wrapper, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]'
  176 |       basic_string(__sv_wrapper __svw, const _Alloc& __a)
      |       ^~~~~~~~~~~~
/usr/include/c++/13/bits/basic_string.h:176:7: note:   candidate expects 2 arguments, 1 provided
match.cpp:32:10: error: 'chat' was not declared in this scope; did you mean 'char'?
   32 |     for (chat ch : s) {
      |          ^~~~
      |          char
match.cpp:50:5: error: expected primary-expression before 'if'
   50 |     if (y != 0) {
      |     ^~
match.cpp:49:6: error: expected ';' before 'if'
   49 |     }
      |      ^
      |      ;
   50 |     if (y != 0) {
      |     ~~
match.cpp:50:5: error: expected primary-expression before 'if'
   50 |     if (y != 0) {
      |     ^~
match.cpp:49:6: error: expected ')' before 'if'
   49 |     }
      |      ^
      |      )
   50 |     if (y != 0) {
      |     ~~
match.cpp:32:9: note: to match this '('
   32 |     for (chat ch : s) {
      |         ^
match.cpp:52:16: error: return-statement with a value, in function returning 'void' [-fpermissive]
   52 |         return 0;
      |                ^