122702024-12-10 21:30:43CsongiFelhasználónevekcpp17Wrong answer 20/10068ms2624 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());
            size_t pos = x.size();
            while (pos > 0 && isdigit(x[pos - 1])) 
            {
                pos--;
            }
            string szamresz = x.substr(pos);
            if (!szamresz.empty()) 
            {
                f.push_back(stoi(szamresz));
            }  
        }
        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
6Accepted1ms500 KiB
7Accepted1ms320 KiB
8Accepted1ms320 KiB
9Accepted1ms340 KiB
10Accepted1ms320 KiB
11Accepted1ms320 KiB
12Accepted1ms320 KiB
13Wrong answer1ms320 KiB
14Wrong answer1ms320 KiB
subtask40/40
15Accepted65ms2396 KiB
16Accepted67ms2480 KiB
17Accepted68ms2532 KiB
18Accepted68ms2624 KiB
19Accepted67ms2488 KiB
20Accepted67ms2488 KiB
21Accepted68ms2592 KiB
22Accepted65ms2480 KiB
23Wrong answer46ms1460 KiB
24Wrong answer48ms1600 KiB
25Wrong answer46ms1460 KiB
26Wrong answer46ms1456 KiB
27Accepted65ms2480 KiB