結果

問題 No.478 一般門松列列
ユーザー femto
提出日時 2017-01-27 22:50:42
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 1,638 ms
コンパイル使用メモリ 166,940 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-23 16:38:09
合計ジャッジ時間 3,102 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int x[4] = { 4, 2, 3, 1 };
int a[100000];

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n; i++) {
		a[i] = x[i % 4];
	}

	for(int i = 0; i < k; i++) {
		if(k % 2 == 0) a[i] = 1000000;
		else a[i] = 0;
	}

	int cnt = 0;
	for(int i = 0; i <= n - 3; i++) {
		if(a[i] < a[i + 1] && a[i + 1] > a[i + 2]) cnt++;
		if(a[i] > a[i + 1] && a[i + 1] < a[i + 2]) cnt++;
	}
	assert(cnt == n - k - 2);

	for(int i = 0; i < n; i++) {
		cout << a[i];
		if(i == n - 1) cout << endl;
		else cout << " ";
	}
}
0