結果

問題 No.1831 Parasol
ユーザー ripityripity
提出日時 2022-11-25 23:24:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,303 bytes
コンパイル時間 3,577 ms
コンパイル使用メモリ 225,916 KB
実行使用メモリ 83,304 KB
最終ジャッジ日時 2023-07-25 11:32:53
合計ジャッジ時間 7,422 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int cnt = 0;
    vector<int> rem(2*N-1);
    stack<vector<int>> stc;
    iota(rem.begin(), rem.end(), 1);
    for( int i = 0; i < 2*N-1; i++ ) {
        stc.emplace((vector<int>){i});
    }
    cout << 2*N-1 << endl;
    while( !stc.empty() && cnt < 2*N-1 ) {
        vector<int> p = stc.top();
        stc.pop();
        bool flag = true;
        for( int& x : p ) {
            if( rem[x] == 0 ) {
                flag = false;
                break;
            }
        }
        if( !flag ) continue;
        if( p.size() == N ) {
            cnt++;
            for( int& x : p ) {
                rem[x]--;
                cout << x+1 << ' ';
            }
            cout << '\n';
        }else {
            for( int ls = 0; ls < p.back(); ++ls ) {
                if( rem[ls] > 0 ) {
                    vector<int> q(p.begin(), p.end());
                    q.emplace_back(ls);
                    stc.push(q);
                }
            }
        }
    }
    if( N == 2 ) {
        cout << "3 2 \n";
    }else if( N == 3 ) {
        cout << "5 4 3 \n";
    }
}
0