結果

問題 No.942 プレゼント配り
ユーザー ianCKianCK
提出日時 2019-12-09 08:13:42
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 922 bytes
コンパイル時間 673 ms
コンパイル使用メモリ 40,984 KB
実行使用メモリ 8,504 KB
最終ジャッジ日時 2023-09-02 12:55:31
合計ジャッジ時間 2,319 ms
ジャッジサーバーID
(参考情報)
judge11 / judge16
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 22 ms
8,320 KB
testcase_02 AC 4 ms
7,648 KB
testcase_03 AC 4 ms
7,660 KB
testcase_04 AC 22 ms
8,496 KB
testcase_05 AC 24 ms
8,268 KB
testcase_06 AC 4 ms
7,648 KB
testcase_07 AC 4 ms
7,728 KB
testcase_08 AC 17 ms
8,332 KB
testcase_09 AC 20 ms
8,456 KB
testcase_10 AC 4 ms
7,648 KB
testcase_11 AC 4 ms
7,652 KB
testcase_12 AC 4 ms
7,580 KB
testcase_13 AC 4 ms
7,652 KB
testcase_14 AC 20 ms
8,140 KB
testcase_15 AC 14 ms
8,412 KB
testcase_16 AC 15 ms
8,428 KB
testcase_17 AC 16 ms
8,504 KB
testcase_18 AC 5 ms
7,652 KB
testcase_19 AC 4 ms
7,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <vector>
using namespace std;
constexpr int kN = int(2E5 + 10);
#define PB push_back
vector<int> ans[kN];

int main() {
	int n, k, need, now;
	scanf("%d%d", &n, &k);
	if (n == k || (long long int) n * (long long int) (n + 1) % (k << 1) != 0) printf("No\n");
	else {
		need = n / k;
		now = 1;
		if (need & 1) {
			for (int i = 1; i <= k; i++) ans[i].PB(i);
			for (int i = 1, j = 0; i <= k; i++, j += 2) {
				if (j >= k) j -= k;
				ans[i].PB(k * 3 - j);
				ans[i].PB((k * 3 + 3) / 2 + j - i);
			}
			need -= 3;
			now = k * 3 + 1;
		}
		while (need) {
			for (int i = 1; i <= k; i++) ans[i].PB(now++);
			for (int i = k; i >= 1; i--) ans[i].PB(now++);
			need -= 2;
		}
		need = n / k;
		printf("Yes\n");
		for (int i = 1; i <= k; i++) {
			printf("%d", ans[i][0]);
			for (int j = 1; j < need; j++) printf(" %d", ans[i][j]);
			printf("\n");
		}
	}
}
0