52792023-04-25 09:46:50kohumarkKígyózó szavakcpp17Runtime error 30/10035ms63784 KiB
#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;

vector<vector<int>> szavak;
vector<pair<int,int>> mima;
int n, m;

void feltolt(vector<int> act, int mi, int ma){
	szavak.push_back(act);
	mima.push_back(make_pair(abs(mi)	,25-ma));
	if((int)act.size()<n) {
		int end=act[(int)act.size()-1]-1;
		act.push_back(act[(int)act.size()-1]-1);
		feltolt(act,min(mi,end),ma);
		act[(int)act.size()-1]=end+2;
		feltolt(act,mi,max(ma,end+2));
	}
}

int main(){
	cin.tie(0); ios_base::sync_with_stdio(false);
	cin >> n >> m;	//a==97 z==122
	vector<int> a; a.push_back(0);
	feltolt(a,0,0);
	int sol[m];  int ma=0;
	for(int i=0; i<m; i++){
		cin >> sol[i]; ma=max(ma,sol[i]);
	}
	pair<int,int> calc[ma];
	int x=0; int s=0; int b=0; int db=(int)szavak.size(); // x az aktuális ssz, b a kezdobetu, s a sorszam
	while(x<ma){
		x++;
		while(true){
			if(s==db){s=0; b++;}
			if(mima[s].first<=b&&mima[s].second>=b){
				calc[x-1] = make_pair(b,s); s++;
				break;
			}
			s++;
		}
	}
	for(int i=0; i<m; i++){
		for(int j=0; j<(int)szavak[calc[sol[i]-1].second].size(); j++) cout << (char)(szavak[calc[sol[i]-1].second][j]+calc[sol[i]-1].first+97);
		cout << '\n';
	}
}
SubtaskSumTestVerdictTimeMemory
base30/100
1Accepted0/03ms1832 KiB
2Accepted0/03ms2316 KiB
3Accepted5/53ms2264 KiB
4Accepted5/53ms2612 KiB
5Accepted5/53ms2680 KiB
6Accepted5/53ms2780 KiB
7Accepted5/53ms3160 KiB
8Accepted5/54ms3520 KiB
9Runtime error0/535ms63784 KiB
10Runtime error0/532ms63552 KiB
11Runtime error0/529ms63300 KiB
12Runtime error0/527ms63048 KiB
13Runtime error0/528ms63052 KiB
14Runtime error0/632ms63028 KiB
15Runtime error0/632ms62776 KiB
16Runtime error0/630ms62668 KiB
17Runtime error0/629ms62664 KiB
18Runtime error0/729ms62636 KiB
19Runtime error0/727ms62416 KiB
20Runtime error0/729ms62416 KiB