184472025-10-22 20:20:00ubormaciDíjazás több helyezettnekcpp17Wrong answer 5/80600ms552 KiB
#include <iostream>
#include <algorithm> // for sort, mainly
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <array>
#include <string>
#include <cstdio>
#include <iterator>
#include <unordered_set>
#include <cstdint> // for int64_t, int32_t, etc
#include <queue>
#include <stack>
#include <deque>
#include <numeric> // gcd, lcm
#include <fstream>
#include <bitset> // for bitset
#include <iomanip>
#include <cassert> // for set with custom ordering
#include <type_traits> // for set with custom ordering
#include <utility> // for swap, forward, etc
using namespace std;

#pragma GCC optimize("O2")
// #pragma GCC optimize("O1","O2","O3","Ofast","unroll-loops")
//#pragma GCC target("sse","sse2","sse3","sse4.1","sse4.2","avx","avx2","fma")

template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { os << '{'; string sep; for (const T &x : v) os << sep << x, sep = ", "; return os << '}'; }
void dbg_out() { cout << endl; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << H; dbg_out(T...); }
#ifdef LOCAL
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

/*
 *
 * notes:
 *
 * int64_t
 * stoi(string s) -> string to int
 * to_string() -> int (or else) to string
 *
 * vector declaration:
 * vector<ll> v(n, 0)
 * vector<vector<ll>> v(n, vector<ll>(n, 0));
 *
 * {if statement} ? {truth value} : {false value}
 *
 * set lower bound/upper bound:
 * 	// . . . m1 . . . d . . . . m2
 *    auto m1_it = b.lower_bound(d);
 *    advance(m1_it, -1);
 *    m1 = *m1_it;
 *	m2 = *b.upper_bound(d);
 *
 * #ifdef LOCAL
 *    freopen("in.txt","r",stdin);
 *    freopen("out.txt","w",stdout);
 * #endif
 *
 * constexpr auto lcm(auto x, auto... xs)
 * {
 *	return ((x = std::lcm(x, xs)), ...);
 * }
 *
 * std::gcd(int a, int b)
 *
 * cout << setprecision(n);
 *
 * set with custom ordering
 * set<ll, decltype(&cmp)> qu(cmp);
 *
 */

typedef int64_t ll;

vector<vector<ll>> sol;

ll gauss(ll n) {

    return (n * (n+1))/2;

}   

ll getsum(ll a, ll b) {

    return gauss(b) - gauss(a-1);

}

void proc(ll curr, vector<ll> v, ll h) {

    // h = moneyleft

    if(curr == 0) {
        v[0] = h;
        sol.push_back(v);
        return;
    }else{

        for(ll i = v[curr+1]+1; i <= h; i++) {

            ll rem = h - i; 
            ll needed = (i+1, i + curr);
            if(needed > rem) {
                break;
            }

            v[curr] = i;
            proc(curr - 1, v, rem);

        }

    }

}

void solve() {

    ll n, w;
    cin >> n >> w;

    vector<ll> v(n+1, 0);
    proc(n-1, v, w);

    for(const auto & s : sol) {
        for(const auto & x : s) {
            if(x == 0) {
                break;
            }
            cout << x << " ";
        }
        cout << "\n";
    }

}

int main()
{
    std::ios_base::sync_with_stdio(false);
    //cin.tie(nullptr);
    //cout.tie(nullptr);

    solve();

    return 0;
}
SubtaskSumTestVerdictTimeMemory
subtask10/0
1Accepted1ms316 KiB
2Wrong answer3ms316 KiB
subtask25/5
3Accepted1ms316 KiB
4Accepted1ms316 KiB
5Accepted1ms316 KiB
6Accepted1ms368 KiB
7Accepted1ms316 KiB
subtask30/5
8Accepted1ms316 KiB
9Accepted1ms316 KiB
10Wrong answer1ms316 KiB
11Wrong answer1ms316 KiB
12Wrong answer1ms316 KiB
subtask40/15
13Accepted1ms316 KiB
14Wrong answer1ms316 KiB
15Wrong answer1ms500 KiB
16Wrong answer1ms316 KiB
17Wrong answer1ms316 KiB
subtask50/15
18Accepted1ms316 KiB
19Wrong answer1ms316 KiB
20Wrong answer1ms316 KiB
21Wrong answer2ms508 KiB
22Wrong answer1ms316 KiB
subtask60/15
23Accepted1ms316 KiB
24Wrong answer3ms316 KiB
25Accepted1ms316 KiB
26Wrong answer1ms316 KiB
27Wrong answer1ms316 KiB
28Wrong answer2ms508 KiB
29Wrong answer1ms316 KiB
30Wrong answer2ms500 KiB
31Wrong answer2ms520 KiB
32Accepted1ms316 KiB
33Wrong answer2ms508 KiB
34Wrong answer4ms316 KiB
35Accepted2ms500 KiB
36Wrong answer3ms316 KiB
37Wrong answer7ms504 KiB
38Wrong answer14ms548 KiB
39Wrong answer13ms328 KiB
subtask70/25
40Accepted1ms316 KiB
41Wrong answer3ms316 KiB
42Accepted1ms316 KiB
43Accepted1ms316 KiB
44Accepted1ms316 KiB
45Accepted1ms368 KiB
46Accepted1ms316 KiB
47Accepted1ms316 KiB
48Accepted1ms316 KiB
49Wrong answer1ms316 KiB
50Wrong answer1ms316 KiB
51Wrong answer1ms316 KiB
52Accepted1ms316 KiB
53Wrong answer1ms316 KiB
54Wrong answer1ms500 KiB
55Wrong answer1ms316 KiB
56Wrong answer1ms316 KiB
57Accepted1ms316 KiB
58Wrong answer1ms316 KiB
59Wrong answer1ms316 KiB
60Wrong answer2ms508 KiB
61Wrong answer1ms316 KiB
62Wrong answer2ms500 KiB
63Wrong answer2ms520 KiB
64Accepted1ms316 KiB
65Wrong answer2ms508 KiB
66Wrong answer4ms316 KiB
67Accepted2ms500 KiB
68Wrong answer3ms316 KiB
69Wrong answer7ms504 KiB
70Wrong answer14ms548 KiB
71Wrong answer13ms328 KiB
72Wrong answer266ms524 KiB
73Wrong answer123ms424 KiB
74Time limit exceeded600ms496 KiB
75Accepted202ms420 KiB
76Time limit exceeded584ms316 KiB
77Time limit exceeded570ms552 KiB
78Time limit exceeded582ms316 KiB
79Time limit exceeded582ms316 KiB
80Time limit exceeded583ms316 KiB
81Time limit exceeded583ms316 KiB