185182025-10-25 16:08:57KristófDíjazás több helyezettnekcpp17Wrong answer 0/80490ms724 KiB
#include <iostream>
#include <vector>



using namespace std;

int k=1;

void kiiras(vector<vector<int>> &helyezes)
{
//cout<<k<<endl<<endl<<endl;
//k++;
for(int i=0;i<helyezes.size();i++)
    {
    for(int l=1;l<helyezes[i].size();l++)
    {
    cout<<helyezes[i][l]<<" ";
    }
    cout<<endl;
    }
//cout<<endl;
}

bool duplicant(vector<vector<int>> &helyezes,vector<int> inp)
{
for(auto x : helyezes)
    {
        x[0]=0;
        inp[0]=0;
    if(x==inp)
        {
        return false;
        }
    }
return true;
}


int main()
{
    int n,h;
    cin>>n>>h;
    vector<vector<int>> helyezesek(1,vector<int> (n+1));
    vector<vector<int>> ezelottihelyezesek(1,vector<int> (n+1));
    int h2=h;
    helyezesek[0][n]=1;
    h2--;
    for(int i=n-1;i>1;i--)
        {
        helyezesek[0][i]=helyezesek[0][i+1]+1;
        h2-=helyezesek[0][i];
        }
    helyezesek[0][1]=h2;
    ezelottihelyezesek=helyezesek;
    kiiras(helyezesek);
    while(!ezelottihelyezesek.empty())
        {
        helyezesek.clear();

        for(auto x : ezelottihelyezesek)
            {
            int i=1;
            //cout<<x.size()<<endl;
            if(x[i]-1>x[i+1]+1)
                {
                //cout<<x[i]<<" 1 "<<x[i+1]<<endl;
                vector<int> tmp=x;
                tmp[i]--;
                tmp[i+1]++;
                //cout<<tmp[i]<<" 1 "<<tmp[i+1]<<endl;
                if(duplicant(helyezesek,tmp))
                    {
                    helyezesek.push_back(tmp);
                    }

                }
            else if(x[1]-1==x[2]){continue;}
            i++;
            while(i+1<=x.size() )
                {
                if(x[i]>x[i+1]+1)
                {
                //cout<<x[i]<<" 2 "<<x[i+1]<<endl;
                vector<int> tmp=x;
                tmp[1]--;
                tmp[i+1]++;
                //cout<<tmp[i]<<" 2 "<<tmp[i+1]<<endl;
                if(duplicant(helyezesek,tmp))
                    {
                    helyezesek.push_back(tmp);
                    }

                }
                i++;
                }
            }
        ezelottihelyezesek=helyezesek;
        kiiras(helyezesek);
        }
    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Wrong answer4ms316 KiB
subtask20/5
3Wrong answer1ms316 KiB
4Wrong answer1ms344 KiB
5Wrong answer1ms364 KiB
6Wrong answer3ms316 KiB
7Wrong answer8ms436 KiB
subtask30/5
8Accepted1ms316 KiB
9Wrong answer1ms508 KiB
10Wrong answer1ms316 KiB
11Wrong answer14ms316 KiB
12Wrong answer490ms724 KiB
subtask40/15
13Accepted1ms316 KiB
14Wrong answer1ms508 KiB
15Wrong answer3ms316 KiB
16Wrong answer14ms508 KiB
17Wrong answer226ms428 KiB
subtask50/15
18Accepted1ms316 KiB
19Accepted4ms424 KiB
20Wrong answer12ms316 KiB
21Wrong answer7ms440 KiB
22Wrong answer1ms316 KiB
subtask60/15
23Accepted1ms508 KiB
24Wrong answer4ms444 KiB
25Accepted1ms316 KiB
26Accepted4ms424 KiB
27Wrong answer12ms316 KiB
28Wrong answer7ms440 KiB
29Wrong answer1ms316 KiB
30Wrong answer16ms652 KiB
31Accepted4ms316 KiB
32Accepted1ms316 KiB
33Wrong answer1ms316 KiB
34Wrong answer8ms400 KiB
35Accepted1ms508 KiB
36Accepted1ms316 KiB
37Wrong answer8ms456 KiB
38Wrong answer8ms508 KiB
39Accepted1ms316 KiB
subtask70/25
40Accepted1ms508 KiB
41Wrong answer4ms444 KiB
42Wrong answer1ms316 KiB
43Wrong answer1ms344 KiB
44Wrong answer1ms364 KiB
45Wrong answer3ms316 KiB
46Wrong answer8ms436 KiB
47Accepted1ms316 KiB
48Wrong answer1ms508 KiB
49Wrong answer1ms316 KiB
50Wrong answer14ms316 KiB
51Wrong answer490ms724 KiB
52Accepted1ms316 KiB
53Wrong answer1ms508 KiB
54Wrong answer3ms316 KiB
55Wrong answer14ms508 KiB
56Wrong answer226ms428 KiB
57Accepted1ms316 KiB
58Accepted4ms424 KiB
59Wrong answer12ms316 KiB
60Wrong answer7ms440 KiB
61Wrong answer1ms316 KiB
62Wrong answer16ms652 KiB
63Accepted4ms316 KiB
64Accepted1ms316 KiB
65Wrong answer1ms316 KiB
66Wrong answer8ms400 KiB
67Accepted1ms508 KiB
68Accepted1ms316 KiB
69Wrong answer8ms456 KiB
70Wrong answer8ms508 KiB
71Accepted1ms316 KiB
72Wrong answer4ms316 KiB
73Accepted1ms316 KiB
74Wrong answer4ms316 KiB
75Accepted1ms316 KiB
76Accepted1ms316 KiB
77Accepted4ms316 KiB
78Accepted1ms316 KiB
79Accepted3ms316 KiB
80Accepted1ms508 KiB
81Accepted1ms316 KiB