122682024-12-10 21:23:35CsongiFelhasználónevekcpp17Runtime error 20/10064ms2584 KiB
#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;
    vector<ll> f(0);
    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());
            f.push_back(stoi(x));
        }
        else if (x == valerio)
        {
            found = true;
            f.push_back(0);
        }
    }
    sort(f.begin(), f.end());
    ll i = 0;
    for (i = 0; i < f.size(); i++)
    {
        if (i != f[i] && found)
        {
            cout << valerio << i << endl;
            return 0;
        }
        else if (!found)
        {
            cout << valerio << endl;
            return 0;
        }
    }
    cout << valerio << i << endl;

    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms508 KiB
2Accepted1ms320 KiB
subtask220/20
3Accepted1ms320 KiB
4Accepted1ms320 KiB
subtask30/40
5Accepted1ms320 KiB
6Accepted1ms520 KiB
7Accepted1ms320 KiB
8Accepted1ms320 KiB
9Accepted1ms320 KiB
10Accepted1ms320 KiB
11Accepted1ms320 KiB
12Accepted1ms384 KiB
13Runtime error3ms320 KiB
14Runtime error3ms320 KiB
subtask40/40
15Accepted63ms2480 KiB
16Accepted63ms2472 KiB
17Accepted63ms2488 KiB
18Accepted63ms2476 KiB
19Accepted64ms2488 KiB
20Accepted63ms2584 KiB
21Accepted64ms2400 KiB
22Accepted63ms2480 KiB
23Runtime error3ms568 KiB
24Runtime error3ms512 KiB
25Runtime error3ms320 KiB
26Runtime error3ms320 KiB
27Accepted63ms2416 KiB