結果

問題 No.942 プレゼント配り
ユーザー kotatsugame
提出日時 2019-12-09 01:34:23
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 799 bytes
コンパイル時間 728 ms
コンパイル使用メモリ 69,896 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-01-03 02:48:25
合計ジャッジ時間 3,060 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 RE * 1
other AC * 14 WA * 4
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:5:1: warning: ISO C++ forbids declaration of ‘main’ with no type [-Wreturn-type]
    5 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;
int N,K;
main()
{
	cin>>N>>K;
	int t=N/K;
	if(t%2==0)
	{
		cout<<"Yes"<<endl;
		for(int i=0;i<K;i++)
		{
			for(int j=0;j<t;j++)
			{
				cout<<(j%2==0?j*K+i+1:j*K+K-i)<<" ";
			}
			cout<<endl;
		}
	}
	else if(t>3&&N%2==1)
	{
		cout<<"Yes"<<endl;
		vector<vector<int> >X(2,vector<int>(K));
		for(int i=0;i<K;i++)
		{
			X[0][i]=i+1;
			X[1][i]=K+i+1;
		}
		for(int i=K/2-1;i>0;i--)
		{
			swap(X[0][K-i],X[0][K-i-1]);
			swap(X[1][i-1],X[1][i]);
		}
		swap(X[0][K-1],X[1][0]);
		for(int i=0;i<K;i++)
		{
			cout<<X[0][i]<<" "<<X[1][i];
			for(int j=2;j<t/2;j++)
			{
				cout<<" "<<(j*K+1+i);
			}
			for(int j=t/2;j<t;j++)
			{
				cout<<" "<<(j*K+K-i);
			}
			cout<<endl;
		}
	}
	else if(t==3)
	{
		return 1;
	}
	else cout<<"No"<<endl;
}
0