99142024-03-18 15:50:00111Kígyózó szavakcpp17Wrong answer 30/1003ms4828 KiB
#include <bits/stdc++.h>
using namespace std;

#define int long long

int mem[26][1001];

int calc(int c,int n){
	if(c<0||c>=26)return 0;
	if(n==1)return 1;
	if(mem[c][n])return mem[c][n];
	return mem[c][n]=1+calc(c-1,n-1)+calc(c+1,n-1);
}

signed main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef CB
	freopen("be2.txt","r",stdin);
//	freopen("out.txt","w",stdout);
#endif
    int H,N;
    cin>>H>>N;
    for(int i=0;i<N;i++){
		int x;
		cin>>x;
		string s;
		int y=0;
		char c='a';
		while((y+=calc(c-'a',H))<x)c++;
		s+=c;
		x-=y-calc(c-'a',H);
		x--;
		while(x>0){
			x--;
			if(c=='a'){
				c++;
			}
			else if(calc(c-1-'a',H-s.size())>x){
				c--;
			}
			else{
				x-=calc(c-1-'a',H-s.size());
				c++;
			}
			s+=c;
		}
		cout<<s<<'\n';
    }
	return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/100
1Accepted0/03ms1848 KiB
2Accepted0/03ms2268 KiB
3Accepted5/53ms2512 KiB
4Accepted5/53ms2696 KiB
5Accepted5/53ms2812 KiB
6Accepted5/53ms2944 KiB
7Accepted5/53ms3032 KiB
8Accepted5/53ms3276 KiB
9Wrong answer0/53ms3408 KiB
10Wrong answer0/53ms3404 KiB
11Wrong answer0/53ms3620 KiB
12Wrong answer0/53ms3880 KiB
13Wrong answer0/53ms4004 KiB
14Wrong answer0/63ms4100 KiB
15Wrong answer0/63ms4400 KiB
16Wrong answer0/63ms4352 KiB
17Wrong answer0/63ms4556 KiB
18Wrong answer0/73ms4752 KiB
19Wrong answer0/73ms4828 KiB
20Wrong answer0/73ms4692 KiB