53372023-04-25 23:33:15kohumarkKígyózó szavakcpp17Wrong answer 5/10029ms3816 KiB
#include <iostream>
using namespace std;
int m=4; int c=0;
int h=0; int n=0;
unsigned long long t[26][1000];

void solveend(int x, int i, int a){
	if(x>0){
		if((unsigned)x<=t[i-1][h-a]&&i>0){cout << (char)(i+96); solveend(x-1,i-1,a+1);}
		else{
			cout << (char)(i+98);
			if(i>0) solveend(x-t[i-1][h-a]-1,i+1,a+1);
			else solveend(x-1,i+1,a+1);
		}
	}
		
}

void solve(int x){
	int i=0;
	while(t[i][h-1]<(unsigned)x){
		x-=t[i][h-1]; i++;
	}
	cout << (char)(i+97);
	solveend(x-1,i,2);
}

int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> h >> n;
	for(int i=0; i<26; i++) t[i][0]=1;
	for(int i=1; i<25; i++) t[i][1]=3;
	t[0][1]=2; t[25][1]=2;	
	for(int j=2; j<h; j++){
		for(int i=0; i<26; i++){
			if(i==0) t[i][j]=t[i][j-1]+t[i+1][j-1]-t[i+1][j-2];
			else if(i==25) t[i][j]=t[i][j-1]+t[i-1][j-1]-t[i-1][j-2];
			else t[i][j]=t[i][j-1]+t[i-1][j-1]-t[i-1][j-2]+t[i+1][j-1]-t[i+1][j-2];
			cout << t[i][j];
		}
	}
	for(int i=0; i<n; i++){int x; cin >> x; solve(x); cout << '\n';}
}

SubtaskSumTestVerdictTimeMemory
base5/100
1Wrong answer0/03ms2124 KiB
2Wrong answer0/03ms2376 KiB
3Accepted5/53ms2560 KiB
4Wrong answer0/53ms2680 KiB
5Wrong answer0/53ms2696 KiB
6Wrong answer0/53ms2700 KiB
7Wrong answer0/53ms2988 KiB
8Wrong answer0/53ms2716 KiB
9Wrong answer0/513ms2880 KiB
10Wrong answer0/512ms3064 KiB
11Wrong answer0/516ms3360 KiB
12Wrong answer0/517ms3588 KiB
13Wrong answer0/529ms3596 KiB
14Wrong answer0/68ms3588 KiB
15Wrong answer0/616ms3572 KiB
16Wrong answer0/610ms3492 KiB
17Wrong answer0/68ms3480 KiB
18Wrong answer0/79ms3692 KiB
19Wrong answer0/728ms3816 KiB
20Wrong answer0/712ms3704 KiB