結果

問題 No.942 プレゼント配り
ユーザー tnakao0123tnakao0123
提出日時 2019-12-07 17:49:29
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,071 bytes
コンパイル時間 682 ms
コンパイル使用メモリ 88,224 KB
実行使用メモリ 14,400 KB
最終ジャッジ日時 2024-06-07 17:30:40
合計ジャッジ時間 3,075 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,320 KB
testcase_01 WA -
testcase_02 AC 4 ms
8,192 KB
testcase_03 AC 4 ms
8,288 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 4 ms
8,076 KB
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 4 ms
8,056 KB
testcase_11 AC 3 ms
8,080 KB
testcase_12 AC 3 ms
8,256 KB
testcase_13 AC 4 ms
8,036 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 5 ms
8,240 KB
testcase_19 AC 3 ms
8,192 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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);
      |   ~~~~~^~~~~~~~~~~~~~~~

ソースコード

diff #

/* -*- 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 i = 0, d = 1; i < k; i++) {
    if (! (i & 1))
      for (int j = 0; j < m; j++) ds[j].push_back(d++);
    else
      for (int j = m - 1; j >= 0; j--) ds[j].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;
}
0