52832023-04-25 11:05:05kohumarkKígyózó szavakcpp17Time limit exceeded 30/100300ms4448 KiB
#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;
vector<int> t; set<int> nums;
map<int,string> sol;
int h, n; int ma=0; int a=1;

void szo(string act){
	if((int)act.length()<=h&&ma>=a){
		if(nums.count(a)==1) sol[a] = act;
		a++;
		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);
	cin >> h >> n;
	for(int i=0; i<n; i++){
		int x; cin >> x;
		nums.insert(x);
		t.push_back(x);
		ma=max(ma,x);
	}
	kigyozo();
	for(int i=0; i<n; i++) cout << sol[t[i]] << '\n';
}
SubtaskSumTestVerdictTimeMemory
base30/100
1Accepted0/03ms1828 KiB
2Accepted0/03ms2068 KiB
3Accepted5/53ms2276 KiB
4Accepted5/53ms2640 KiB
5Accepted5/53ms2880 KiB
6Accepted5/53ms3240 KiB
7Accepted5/53ms3284 KiB
8Accepted5/54ms3292 KiB
9Time limit exceeded0/5300ms2672 KiB
10Time limit exceeded0/5268ms2784 KiB
11Time limit exceeded0/5259ms2996 KiB
12Time limit exceeded0/5240ms3104 KiB
13Time limit exceeded0/5263ms3724 KiB
14Time limit exceeded0/6272ms3124 KiB
15Time limit exceeded0/6268ms3584 KiB
16Time limit exceeded0/6279ms3376 KiB
17Time limit exceeded0/6275ms4224 KiB
18Time limit exceeded0/7244ms3764 KiB
19Time limit exceeded0/7268ms4448 KiB
20Time limit exceeded0/7252ms3672 KiB