結果
問題 | No.478 一般門松列列 |
ユーザー |
![]() |
提出日時 | 2017-01-28 01:09:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 1,467 bytes |
コンパイル時間 | 1,733 ms |
コンパイル使用メモリ | 169,500 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-23 18:42:43 |
合計ジャッジ時間 | 3,290 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 34 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i,x,y) for(int i=(x);i<(y);++i) #define debug(x) #x << "=" << (x) #ifdef DEBUG #define _GLIBCXX_DEBUG #define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl #else #define print(x) #endif const int inf=1e9; const int64_t inf64=1e18; const double eps=1e-9; template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (const auto &v : vec) { os << v << ","; } os << "]"; return os; } void solve(){ int n,k,l; cin >> n >> k; l=n-k-2; vector<int> a(n),b(n); rep(i,1,n){ if(b[i-1]==1){ a[i]=min(a[i-1],a[i-2])-1; if(l>0){ b[i]=-1; --l; } } if(b[i-1]==-1){ a[i]=max(a[i-1],a[i-2])+1; if(l>0){ b[i]=1; --l; } } if(b[i-1]==0){ if(l>0){ a[i]=a[i-1]+1; b[i]=1; --l; }else a[i]=a[i-1]; } } int mi=*min_element(a.begin(),a.end()); rep(i,0,n) a[i]-=mi; if(l!=0) cout << -1 << endl; else{ cout << a[0]; rep(i,1,n) cout << " " << a[i]; cout << endl; } } int main(){ std::cin.tie(0); std::ios::sync_with_stdio(false); cout.setf(ios::fixed); cout.precision(10); solve(); return 0; }