結果

問題 No.942 プレゼント配り
ユーザー iqueue02
提出日時 2019-12-05 18:36:08
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 881 bytes
コンパイル時間 1,879 ms
コンパイル使用メモリ 168,324 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-21 13:53:24
合計ジャッジ時間 3,370 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n, k;
  cin >> n >> k;
  if (n == 1 && k == 1) {
    cout << "Yes" << endl;
    cout << 1 << endl;
    return 0;
  }
  if (n & 1) {
    cout << "No" << endl;
    return 0; 
  } else {
    int m = n / k;
    if (m & 1 || k == 1) {
      cout << "No" << endl;
      return 0;
    } else {
      cout << "Yes" << endl;
      vector<int> l(n/2), r(n/2);
      for (int i = 0; i < n/2 ; i++) l[i] = n/2 - i;
      for (int i = 1; i <= n/2; i++) r[i-1] = i + n/2;
      int cnt = 0;
      m /= 2;
      for (int i = 0; i < n/2; i++) {
        cout << l[i] << " " << r[i] << " ";
        cnt++;
        if (cnt == m) {
          cnt = 0;
          cout << endl;
        }
      }
    }
  }
  return 0;
}
0