結果

問題 No.942 プレゼント配り
ユーザー Mayimg
提出日時 2020-07-26 14:47:21
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 828 bytes
コンパイル時間 2,129 ms
コンパイル使用メモリ 196,692 KB
最終ジャッジ日時 2025-01-12 05:55:57
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11 WA * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n, k;
  cin >> n >> k;
  if (k == 1) {
    for (int i = 1; i <= n; i++) {
      if (i > 1) cout << " ";
      cout << i;
    }
    cout << '\n';
  }
  if (n % 2 != 0) {
    cout << "No\n";
    return 0;
  } else if (n == 1) {
    cout << 1 << '\n';
    return 0;
  }
  if ((n / k) % 2 != 0) {
    cout << "No\n";
    return 0;
  }
  int t = n / k / 2;
  vector<pair<int, int>> p;
  for (int i = 0; i < n / 2; i++) {
    p.emplace_back(i, n - 1 - i);
  }
  cout << "Yes\n";
  int c = 0;
  for (int i = 0; i < k; i++) {
    for (int j = 0; j < t; j++) {
      if (j > 0) cout << " ";
      cout << p[c].first + 1 << " " << p[c].second + 1;
      c++;
    }
    cout << '\n';
  }
  return 0;
}
0