194242025-12-09 09:45:23gkataDíjazás több helyezettnekcpp17Time limit exceeded 5/80600ms556 KiB

// dijazas.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include<queue>

using namespace std;

int n, p, m, s, s2;
vector<int>x,st;

void kiir(int k)
{
    s = 0;
    s2 = 0;
    for (int j = 1; j <= k; j++) s += x[j];
    if (s == n)
    {
        for (int j = k; j >= 1; --j)
            cout << x[j] << " ";
        cout << endl;
    }
}

void back(int k)
{

    for (int i = x[k - 1] + 1; i <= (n - s2); ++i)
    {
        if (st[i] == 0 && x[k - 1] < i)
        {

            x[k] = i;
            st[i] = 1;
            if (k == p)
                kiir(k);
            else
                back(k + 1);
            st[i] = 0;
        }
    }
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> p >> n;

    x.resize(p + 1);
    st.resize(n + 1);

    back(1);
}

// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started: 
//   1. Use the Solution Explorer window to add/manage files
//   2. Use the Team Explorer window to connect to source control
//   3. Use the Output window to see build output and other messages
//   4. Use the Error List window to view errors
//   5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
//   6. In the future, to open this project again, go to File > Open > Project and select the .sln file
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Time limit exceeded580ms424 KiB
subtask25/5
3Accepted1ms316 KiB
4Accepted1ms432 KiB
5Accepted1ms316 KiB
6Accepted1ms316 KiB
7Accepted1ms316 KiB
subtask30/5
8Accepted1ms316 KiB
9Accepted1ms316 KiB
10Wrong answer1ms332 KiB
11Wrong answer1ms316 KiB
12Wrong answer4ms316 KiB
subtask40/15
13Accepted1ms316 KiB
14Wrong answer1ms336 KiB
15Wrong answer2ms316 KiB
16Wrong answer3ms316 KiB
17Wrong answer6ms428 KiB
subtask50/15
18Accepted1ms316 KiB
19Wrong answer16ms424 KiB
20Wrong answer93ms424 KiB
21Time limit exceeded593ms424 KiB
22Time limit exceeded575ms496 KiB
subtask60/15
23Accepted1ms316 KiB
24Time limit exceeded586ms508 KiB
25Accepted1ms316 KiB
26Wrong answer16ms424 KiB
27Wrong answer93ms424 KiB
28Time limit exceeded593ms424 KiB
29Time limit exceeded575ms496 KiB
30Time limit exceeded587ms428 KiB
31Time limit exceeded587ms512 KiB
32Time limit exceeded600ms344 KiB
33Time limit exceeded579ms316 KiB
34Time limit exceeded579ms424 KiB
35Time limit exceeded579ms508 KiB
36Time limit exceeded598ms316 KiB
37Time limit exceeded579ms316 KiB
38Time limit exceeded580ms508 KiB
39Time limit exceeded580ms508 KiB
subtask70/25
40Accepted1ms316 KiB
41Time limit exceeded586ms508 KiB
42Accepted1ms316 KiB
43Accepted1ms432 KiB
44Accepted1ms316 KiB
45Accepted1ms316 KiB
46Accepted1ms316 KiB
47Accepted1ms316 KiB
48Accepted1ms316 KiB
49Wrong answer1ms332 KiB
50Wrong answer1ms316 KiB
51Wrong answer4ms316 KiB
52Accepted1ms316 KiB
53Wrong answer1ms336 KiB
54Wrong answer2ms316 KiB
55Wrong answer3ms316 KiB
56Wrong answer6ms428 KiB
57Accepted1ms316 KiB
58Wrong answer16ms424 KiB
59Wrong answer93ms424 KiB
60Time limit exceeded593ms424 KiB
61Time limit exceeded575ms496 KiB
62Time limit exceeded587ms428 KiB
63Time limit exceeded587ms512 KiB
64Time limit exceeded600ms344 KiB
65Time limit exceeded579ms316 KiB
66Time limit exceeded579ms424 KiB
67Time limit exceeded579ms508 KiB
68Time limit exceeded598ms316 KiB
69Time limit exceeded579ms316 KiB
70Time limit exceeded580ms508 KiB
71Time limit exceeded580ms508 KiB
72Time limit exceeded577ms420 KiB
73Time limit exceeded578ms332 KiB
74Time limit exceeded578ms316 KiB
75Time limit exceeded578ms500 KiB
76Time limit exceeded579ms316 KiB
77Time limit exceeded580ms316 KiB
78Time limit exceeded580ms512 KiB
79Time limit exceeded580ms556 KiB
80Time limit exceeded589ms316 KiB
81Time limit exceeded589ms316 KiB