97202024-03-03 16:13:26csdavidKígyózó szavakcpp17Wrong answer 30/1008ms4000 KiB
#include <iostream>
#include <fstream>
#include <stack>
using namespace std;

int main()
{
    stack<int> szamok;
    //ofstream fout("szamok.txt");
    //ifstream fin("be2.txt");
    int h, n;
    int utolso=0, aorb=0;
    cin >> h >> n;
    int horiginal=h;
    string eleje = "";
    while(h>33){
        eleje.push_back('a');

        aorb=1;
        h--;
        if(h>33){
            eleje.push_back('b');
            aorb=2;
        }
        h--;
    }
    if(aorb){
        eleje.pop_back();
    }



    long long a[h][28];
    for(auto& alma:a[1])
    {
        alma=1;
    }
    for(auto& alma:a[0])
    {
        alma=1;
    }
    for(int i=0; i<h; i++){
        a[i][0]=0;
        a[i][27]=0;
    }

    /*for(auto& alma:a[0]){
        cout << alma << " ";
    }
    cout << endl;*/
    for(int i=1; i<h; i++){
            //cout << "a";
        for(int j=1; j<27; j++){
            //cout << a[i-1][j-1] << endl;
            a[i][j]=a[i-1][j-1]+/*a[i-1][j]+*/a[i-1][j+1];
            //cout << "b";
        }
    }
    //cout << '\n';
    //long long kakadudu;
    //long long osszes[28];
    //fill(osszes, osszes+28, 0);
    /*for(auto& alma:a){
            kakadudu=0;
        for(auto& picu:alma){
            fout << picu << " ";
            //kakadudu+=picu;
        }
        fout << endl;
    }*/
    /*for(int i=0; i<h; i++){   //osszes kiszamolasa
        for(int j=0; j<28; j++){
            osszes[j]+=a[i][j];
        }
    }*/

    for(int i=1; i<h; i++){
        for(int j=1; j<27; j++){
            a[i][j]+=a[i-1][j];
            //cout << a[i][j] << " ";
        }
        //cout << endl;
    }




    /*for(auto& apl:osszes){
        cout << apl << " ";
    }*/
    long long osszeg[h][28];
    fill(osszeg[0], osszeg[0]+28, 1);
    osszeg[0][0]=0;
    osszeg[0][27]=0;
    for(int i=1; i<h; i++){
        for(int j=0; j<28; j++){
            osszeg[i][j]=osszeg[i-1][j]+a[i][j];
        }
    }

    /*for(auto& xy:osszeg){
        for(auto& yx:xy){
            cout << yx << " ";
        }
        cout << endl;
    }*/

    //cout << "eleje: " << eleje << endl;
    int x;
    int sor = h-1, i;
    string vege;
    for(int it=0; it<n; it++){
        cin >> x;
        vege.clear();
        utolso=aorb;
        sor=h-1;
        if(utolso==0){
            utolso=1;
            while(x>a[sor][utolso]){
                x-=a[sor][utolso];
                utolso++;
            }
            //vege.push_back(utolso+96);
        }
        else{
            sor=horiginal-1;
            while(sor>32&&x>0){
                x--;
                sor--;
                vege.push_back('a');
                utolso=1;
                if(sor>32&&x>0){
                    x--;
                    sor--;
                    vege.push_back('b');
                    utolso=2;
                }
            }
            vege.pop_back();
        }

        sor--;
        while(x>0&&sor>=0){
            //cout << "sor: " << sor << endl << "utolso: " << utolso << endl << "x: " << x << endl<< "a[sor][utolso-1] = " << a[sor][utolso] << endl << endl;
            if(x==1){
                //vege.push_back(utolso+96);
                x--;
            }
            else if(a[sor][utolso-1]>=x-1){
                x--;
                vege.push_back(utolso+96);
                //x-=a[sor][utolso];
                utolso--;
            }
            else{
                vege.push_back(utolso+96);
                x-=a[sor][utolso-1];
                x--;
                utolso++;
            }
            sor--;


        }
        vege.push_back(utolso+96);





        cout << /*eleje <<*/ vege << endl;

    }





    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/100
1Accepted0/03ms1808 KiB
2Accepted0/03ms2000 KiB
3Accepted5/53ms2220 KiB
4Accepted5/53ms2432 KiB
5Accepted5/53ms2512 KiB
6Accepted5/54ms2640 KiB
7Accepted5/54ms2848 KiB
8Accepted5/54ms3000 KiB
9Wrong answer0/54ms3140 KiB
10Wrong answer0/54ms3364 KiB
11Wrong answer0/54ms3436 KiB
12Wrong answer0/54ms3452 KiB
13Wrong answer0/57ms3604 KiB
14Wrong answer0/64ms3476 KiB
15Wrong answer0/64ms3448 KiB
16Wrong answer0/66ms3452 KiB
17Wrong answer0/66ms3580 KiB
18Wrong answer0/74ms3788 KiB
19Wrong answer0/78ms4000 KiB
20Wrong answer0/74ms3876 KiB