104202024-04-02 00:09:36111Felhasználónevekcpp17Wrong answer 20/100155ms22472 KiB
#include <bits/stdc++.h>
using namespace std;

// #define int long long

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	string S;
	cin>>S;
	int N;
	cin>>N;
	set<int>s;
	for(int i=0;i<N;i++){
		string z;
		cin>>z;
		if(z.substr(0,S.size())==S){
			if(z.size()==S.size()){
				s.insert(0);
			}
			else{
				string zz=z.substr(S.size());
				int x=0;
				for(char c:zz){
					if(x>1000000||!isdigit(c)){
						x=-1;
						break;
					}
					x*=10;
					x+=c-'0';
				}
				s.insert(x);
			}
		}
	}
	int i=0;
	while(s.count(i)){
		i++;
	}
	if(i){
		S+=to_string(i);
	}
	cout<<S<<'\n';
	return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted3ms2100 KiB
2Accepted3ms2152 KiB
subtask220/20
3Accepted3ms2356 KiB
4Accepted3ms2596 KiB
subtask30/40
5Accepted3ms2716 KiB
6Accepted3ms2776 KiB
7Accepted3ms2908 KiB
8Accepted3ms3184 KiB
9Accepted3ms3052 KiB
10Accepted3ms3296 KiB
11Accepted3ms3312 KiB
12Accepted2ms3280 KiB
13Wrong answer2ms3268 KiB
14Wrong answer2ms3308 KiB
subtask40/40
15Accepted122ms22028 KiB
16Accepted119ms22032 KiB
17Accepted120ms22024 KiB
18Accepted128ms22024 KiB
19Accepted143ms22080 KiB
20Accepted145ms22372 KiB
21Accepted143ms22324 KiB
22Accepted155ms22328 KiB
23Wrong answer46ms7448 KiB
24Wrong answer46ms7708 KiB
25Wrong answer46ms7740 KiB
26Wrong answer46ms7652 KiB
27Wrong answer144ms22472 KiB