結果
| 問題 | 
                            No.942 プレゼント配り
                             | 
                    
| コンテスト | |
| ユーザー | 
                             ei13337
                         | 
                    
| 提出日時 | 2019-12-01 00:49:45 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,384 bytes | 
| コンパイル時間 | 707 ms | 
| コンパイル使用メモリ | 83,176 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-14 09:47:24 | 
| 合計ジャッジ時間 | 2,438 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 17 WA * 1 | 
ソースコード
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
int main() {
    int n, k;
    cin >> n >> k;
    int m = n / k;
    if(n == 1) {
        cout << "Yes" << endl;
        cout << 2 << endl;
        return 0;
    }
    if((n % 2 == 0 && m % 2 == 1) || m == 1) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    if(k == 1) {
        for(int i = 0; i < n; i++) {
            if(i) cout << " ";
            cout << i + 1;
        }
        cout << endl;
        return 0;
    }
    if(m % 2 == 0) {
        for(int i = 0; i < k; i++) {
            for(int j = 0; j < m; j++) {
                if(j) cout << " ";
                if(j % 2 == 0) cout << j * k + 1 + i;
                else cout << (j + 1) * k - i;
            }
            cout << endl;
        }
    } else {
        for(int i = 0; i < k; i++) {
            int a = 1 + i;
            int b = (k + 1) + (k / 2 + i) % k;
            int c = (k + (k + 1 + k / 2) + 2 * k + 1) - a - b;
            cout << a << " " << b << " " << c;
            for(int j = 3; j < m; j++) {
                cout << " ";
                if(j % 2 == 0) cout << j * k + 1 + i;
                else cout << (j + 1) * k - i;
            }
            cout << endl;
        }
    }
    return 0;
}
            
            
            
        
            
ei13337