結果
| 問題 |
No.942 プレゼント配り
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2019-12-07 17:52:39 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,039 bytes |
| コンパイル時間 | 1,583 ms |
| コンパイル使用メモリ | 86,204 KB |
| 実行使用メモリ | 9,240 KB |
| 最終ジャッジ日時 | 2024-12-26 01:08:13 |
| 合計ジャッジ時間 | 2,927 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 14 WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:45:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
45 | scanf("%d%d", &n, &k);
| ~~~~~^~~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 942.cc: No.942 プレゼント配り - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_N = 200000;
/* typedef */
typedef vector<int> vi;
/* global variables */
vi ds[MAX_N];
/* subroutines */
/* main */
int main() {
int n, k;
scanf("%d%d", &n, &k);
int m = n / k;
if (k > 1 && (m & 1)) {
puts("No");
return 0;
}
for (int d = 1, x = 0, dx = 1; d <= n; d++, x += dx) {
if (x < 0) x = 0, dx = 1;
else if (x >= k) x = k - 1, dx = -1;
ds[x].push_back(d);
}
puts("yes");
for (int i = 0; i < k; i++) {
for (int j = 0; j < m; j++) {
if (j) putchar(' ');
printf("%d", ds[i][j]);
}
putchar('\n');
}
return 0;
}
tnakao0123