122712024-12-10 21:34:18CsongiFelhasználónevekcpp17Forditási hiba
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    string valerio; cin >> valerio;
    ll n; cin >> n;
    string x;
    set<ll> f;
    bool found = false;
    for (ll i = 0; i < n; i++)
    {
        cin >> x;
        if (x.find(valerio) != string::npos && x.length() > valerio.length())
        {
            x.erase(x.find(valerio), valerio.length());
            size_t pos = x.size();
            while (pos > 0 && isdigit(x[pos - 1])) 
            {
                pos--;
            }
            string szamresz = x.substr(pos);
            if (!szamresz.empty()) 
            {
                f.insert(stoi(szamresz));
            }  
        }
        else if (x == valerio)
        {
            found = true;
            f.insert(0);
        }
    }
    sort(f.begin(), f.end());
    ll i = 0;
    for (i = 0; i < f.size(); i++)
    {
        if (f.find(i) != f.end() && found)
        {
            cout << valerio << i << endl;
            return 0;
        }
        else if (!found)
        {
            cout << valerio << endl;
            return 0;
        }
    }
    cout << valerio << i << endl;

    return 0;
}
Forditási hiba
open /var/local/lib/isolate/439/box/a.out: no such file or directory
In file included from /usr/include/c++/12/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:65,
                 from main.cpp:1:
/usr/include/c++/12/bits/stl_algo.h: In instantiation of 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = _Rb_tree_const_iterator<long long int>; _Compare = __gnu_cxx::__ops::_Iter_less_iter]':
/usr/include/c++/12/bits/stl_algo.h:4820:18:   required from 'void std::sort(_RAIter, _RAIter) [with _RAIter = _Rb_tree_const_iterator<long long int>]'
main.cpp:37:9:   required from here
/usr/include/c++/12/bits/stl_algo.h:1938:50: error: no match for 'operator-' (operand types are 'std::_Rb_tree_const_iterator<long long int>' and 'std::_Rb_tree_const_iterator<long long int>')
 1938 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/12/bits/stl_algobase.h:67,
                 from /usr/include/c++/12/bits/specfun.h:45,
                 from /usr/include/c++/12/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/12/bits/stdc++.h:41:
/usr/include/c++/12/bits/stl_iterator.h:621:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  621 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/12/bits/stl_iterator.h:621:5: note:   template argument deduction/substitution failed:
/usr/include/c++/12/bits/stl_algo.h:1938:50: note:   'std::_Rb_tree_const_iterator<long long int>' is not derived from 'const std::reverse_iterator<_Iterator>'
 1938 |                                 std::__lg(__last - __first) * 2,
      |                                           ~~~~~~~^~~~~~~~~
/usr/include/c++/12/bits/stl_iterator.h:1778:5: n...