結果
| 問題 |
No.1061 素敵な数列
|
| コンテスト | |
| ユーザー |
kyort0n
|
| 提出日時 | 2020-05-22 21:56:24 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 25 ms / 2,000 ms |
| コード長 | 1,596 bytes |
| コンパイル時間 | 1,525 ms |
| コンパイル使用メモリ | 173,324 KB |
| 実行使用メモリ | 6,016 KB |
| 最終ジャッジ日時 | 2024-10-05 17:11:49 |
| 合計ジャッジ時間 | 5,127 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
if(a < b) {
a = b;
return true;
}
return false;
}
template<class T>
inline bool chmin(T &a, T b) {
if(a > b) {
a = b;
return true;
}
return false;
}
const long long INF = 1e18;
//const ll mod = 1000000007;
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll N;
cin >> N;
if(N == 1) {
cout << "0 0 0" << endl;
return 0;
}
if(N == 2) {
cout << -1 << endl;
return 0;
}
deque<ll> zero, one, two;
ll c = N - 1;
N--;
N--;
ll onenum = (N + 2) / 3;
ll twonum = (N + 1) / 3;
for(ll i = 0; i <= N; i += 3) {
zero.push_front(i);
zero.push_front(i);
zero.push_back(i);
}
one.push_back(c);
ll rest = c - onenum - twonum;
for(ll i = 1; i <= N; i += 3) {
one.push_back(i);
one.push_front(i);
if(rest) {
one.push_back(i);
rest--;
} else {
one.push_front(i);
}
}
two.push_back(c);
two.push_back(c);
for(ll i = 2; i <= N; i += 3) {
two.push_back(i);
two.push_front(i);
if(rest) {
two.push_front(i);
rest--;
} else {
two.push_back(i);
}
}
for(auto c : zero) cout << c << " ";
for(auto c : one) cout << c << " ";
for(auto c : two) cout << c << " ";
return 0;
}
kyort0n