結果
| 問題 | 
                            No.942 プレゼント配り
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Rubikun
                         | 
                    
| 提出日時 | 2019-12-05 00:15:12 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,701 bytes | 
| コンパイル時間 | 1,687 ms | 
| コンパイル使用メモリ | 172,508 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-12-14 16:27:29 | 
| 合計ジャッジ時間 | 3,326 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 17 WA * 1 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=100000007,MAX=200005;
const ll INF=1LL<<60;
int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll N,K;cin>>N>>K;
    if((1+N)*N/2%K==0){
        if(N/K%2==0){
            cout<<"YES"<<endl;
            for(int i=1;i<=K;i++){
                for(int j=1;j<=N/K;j++){
                    if(j%2==0){
                        cout<<j*K-(i-1)<<" ";
                    }else{
                        cout<<(j-1)*K+i<<" ";
                    }
                }
                cout<<endl;
            }
        }else if(N/K>=K&&(N/K-K)%2==0){
            cout<<"YES"<<endl;
            vector<vector<int>> S(K,vector<int>(N/K,0));
            
            int now=1;
            for(int j=0;j<K;j++){
                for(int i=0;i<K;i++){
                    S[(i+j)%K][j]=now;
                    now++;
                }
            }
            
            for(int j=K;j<N/K;j++){
                if((j-K)%2==0){
                    for(int i=0;i<K;i++){
                        S[i][j]=now;
                        now++;
                    }
                }else{
                    for(int i=0;i<K;i++){
                        S[K-1-i][j]=now;
                        now++;
                    }
                }
            }
            
            for(int i=0;i<K;i++){
                for(int j=0;j<N/K;j++){
                    cout<<S[i][j]<<" ";
                }
                cout<<endl;
            }
        }else cout<<"NO"<<endl;
    }else cout<<"NO"<<endl;
    
}
            
            
            
        
            
Rubikun