結果

問題 No.942 プレゼント配り
ユーザー chocopuuchocopuu
提出日時 2019-12-05 03:56:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,363 bytes
コンパイル時間 1,539 ms
コンパイル使用メモリ 171,356 KB
実行使用メモリ 7,984 KB
最終ジャッジ日時 2023-08-21 23:31:01
合計ジャッジ時間 4,047 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 21 ms
5,016 KB
testcase_05 AC 21 ms
5,056 KB
testcase_06 AC 4 ms
7,984 KB
testcase_07 WA -
testcase_08 AC 17 ms
4,424 KB
testcase_09 WA -
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 19 ms
4,728 KB
testcase_15 AC 13 ms
4,484 KB
testcase_16 AC 16 ms
4,880 KB
testcase_17 AC 15 ms
4,692 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
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;}
constexpr long long INF = 1e18;

signed main(){
	int N,K;
	cin>>N>>K;
	int sum = N * (N + 1) / 2;
	if(sum % K){
		cout << "No" << endl;
		return 0;
	}
	vector<vector<int>>ans(K);
	if(K % 2){
		if(N == K){
			cout << "No" << endl;
			return 0;
		}
		REP(i,2*K){
			if(i % 2)ans[i % K].push_back(K + i / 2);
			else ans[i % K].push_back(i / 2);
		}
		REP(i,K){
			ans[i].push_back(3 * K - i - 1);
		}
		int turn = N / K - 3;
		REP(i,turn / 2){
			REP(j,K){
				ans[j].push_back(i * 2 * K + 3 * K + j);
				ans[j].push_back(i * 2 * K + 3 * K + 2 * K - j - 1);
			}
		}
	}else{
		int turn = N / K;
		REP(i,turn / 2){
			REP(j,K){
				ans[j].push_back(i * 2 * K + j);
				ans[j].push_back(i * 2 * K + 2 * K - j - 1);
			}
		}
	}
	cout << "Yes" << endl;
	REP(i,K){
		REP(j,ans[i].size()){
			if(j)cout << " ";
			cout << ans[i][j] + 1;
		}
		cout << endl;
	}
}
0