結果
| 問題 |
No.1831 Parasol
|
| コンテスト | |
| ユーザー |
ripity
|
| 提出日時 | 2022-11-25 23:36:49 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,182 bytes |
| コンパイル時間 | 9,715 ms |
| コンパイル使用メモリ | 285,688 KB |
| 最終ジャッジ日時 | 2025-02-09 00:58:07 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 17 TLE * 2 |
ソースコード
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#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() ) {
vector<int> p = stc.top();
stc.pop();
for( int& x : p ) {
if( rem[x] == 0 ) goto LABEL;
}
if( p.size() == N ) {
++cnt;
for( int& x : p ) {
--rem[x];
cout << x+1 << ' ';
}
cout << '\n';
}else {
for( int ls = 0, B = p.back(); ls < B; ++ls ) {
if( rem[ls] > 0 ) {
p.emplace_back(ls);
stc.push(p);
p.pop_back();
}
}
}
LABEL: {}
}
if( N == 2 ) {
cout << "3 2 \n";
}else if( N == 3 ) {
cout << "5 4 3 \n";
}
}
ripity