122672024-12-10 21:22:13CsongiFelhasználónevekcpp17Runtime error 20/10061ms1640 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;
    int n; cin >> n;
    string x;
    vector<int> f(0);
    bool found = false;
    for (int 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());
    int 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
2Accepted1ms320 KiB
subtask220/20
3Accepted1ms320 KiB
4Accepted1ms320 KiB
subtask30/40
5Accepted1ms320 KiB
6Accepted1ms320 KiB
7Accepted1ms320 KiB
8Accepted1ms392 KiB
9Accepted1ms320 KiB
10Accepted1ms320 KiB
11Accepted1ms320 KiB
12Accepted1ms320 KiB
13Runtime error3ms320 KiB
14Runtime error3ms492 KiB
subtask40/40
15Accepted59ms1600 KiB
16Accepted61ms1456 KiB
17Accepted61ms1572 KiB
18Accepted61ms1460 KiB
19Accepted61ms1464 KiB
20Accepted61ms1460 KiB
21Accepted61ms1640 KiB
22Accepted61ms1512 KiB
23Runtime error3ms756 KiB
24Runtime error3ms320 KiB
25Runtime error3ms320 KiB
26Runtime error3ms320 KiB
27Accepted59ms1348 KiB