122692024-12-10 21:27:51CsongiFelhasználónevekcpp17Wrong answer 20/10064ms2656 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());
            if (all_of(x.begin(), x.end(), ::isdigit))
            {
                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
1Accepted1ms320 KiB
2Accepted1ms508 KiB
subtask220/20
3Accepted1ms320 KiB
4Accepted1ms320 KiB
subtask30/40
5Accepted1ms320 KiB
6Accepted1ms320 KiB
7Accepted1ms320 KiB
8Accepted1ms320 KiB
9Accepted1ms320 KiB
10Accepted1ms320 KiB
11Accepted1ms320 KiB
12Accepted1ms320 KiB
13Wrong answer1ms320 KiB
14Wrong answer1ms320 KiB
subtask40/40
15Accepted64ms2388 KiB
16Accepted64ms2480 KiB
17Accepted64ms2540 KiB
18Accepted64ms2480 KiB
19Accepted64ms2656 KiB
20Accepted64ms2480 KiB
21Accepted64ms2488 KiB
22Accepted64ms2424 KiB
23Wrong answer37ms1460 KiB
24Wrong answer39ms1456 KiB
25Wrong answer39ms1456 KiB
26Wrong answer37ms1460 KiB
27Accepted64ms2484 KiB