50372023-04-10 14:25:16kohumarkKígyózó szavakcpp17Time limit exceeded 30/100300ms4768 KiB
#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;
vector<int> t; set<int> nums;
map<int,string> sol;
int h; int a=1;

void szo(string act){
	if((int)act.length()<=h){
		if(nums.count(a)==1) sol[a] = act;
		a++; if(a<1e9){
		if(act[act.length()-1]>('a')) szo(act+(char)(act[act.length()-1]-1));
		if(act[act.length()-1]<('z')) szo(act+(char)(act[act.length()-1]+1));}
	}
}

void kigyozo(){
	for(char a='a'; a<='z'; a++){
		string x(1,a);
		szo(x);
	}
}

int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >> h >> n;
	for(int i=0; i<n; i++){
		int x; cin >> x;
		nums.insert(x);
		t.push_back(x);
	}
	kigyozo();
	for(int i=0; i<n; i++) cout << sol[t[i]] << '\n';
}
SubtaskSumTestVerdictTimeMemory
base30/100
1Accepted0/03ms1828 KiB
2Accepted0/03ms2068 KiB
3Accepted5/53ms2240 KiB
4Accepted5/53ms2600 KiB
5Accepted5/53ms2836 KiB
6Accepted5/53ms3100 KiB
7Accepted5/54ms3396 KiB
8Accepted5/54ms3556 KiB
9Time limit exceeded0/5300ms2892 KiB
10Time limit exceeded0/5266ms3680 KiB
11Time limit exceeded0/5280ms3260 KiB
12Time limit exceeded0/5247ms3412 KiB
13Time limit exceeded0/5236ms4304 KiB
14Time limit exceeded0/6268ms4196 KiB
15Time limit exceeded0/6300ms3508 KiB
16Time limit exceeded0/6268ms4292 KiB
17Time limit exceeded0/6268ms3496 KiB
18Time limit exceeded0/7263ms4284 KiB
19Time limit exceeded0/7236ms4284 KiB
20Time limit exceeded0/7268ms4768 KiB