結果

問題 No.942 プレゼント配り
ユーザー chocopuuchocopuu
提出日時 2019-12-05 02:04:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,007 bytes
コンパイル時間 1,491 ms
コンパイル使用メモリ 170,012 KB
実行使用メモリ 14,164 KB
最終ジャッジ日時 2023-08-21 14:58:48
合計ジャッジ時間 4,065 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 20 ms
14,164 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 WA -
testcase_15 AC 14 ms
4,756 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 2 ms
4,384 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(N % K || sum % K){
		cout << "No" << endl;
		return 0;
	}
	vector<vector<int>>ans(K);
	REP(i,N/K){
		REP(j,K){
			ans[(j + i) % K].push_back(i * K + j);
		}
	}
	REP(i,K){
		if(sum / K != accumulate(ALL(ans[i]),0) + N / K){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	REP(i,K){
		REP(j,ans[i].size()){
			if(j)cout<<" ";
			cout << ans[i][j] + 1;
		}
		cout << endl;
	}
}
0