結果

問題 No.2112 All 2x2 are Equal
ユーザー 👑 kmjpkmjp
提出日時 2022-10-29 00:02:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 1,457 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 201,504 KB
実行使用メモリ 7,428 KB
最終ジャッジ日時 2023-09-20 07:23:09
合計ジャッジ時間 8,148 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 4 ms
4,376 KB
testcase_03 AC 4 ms
4,376 KB
testcase_04 AC 35 ms
6,628 KB
testcase_05 AC 42 ms
5,556 KB
testcase_06 AC 72 ms
7,168 KB
testcase_07 AC 24 ms
4,808 KB
testcase_08 AC 60 ms
7,304 KB
testcase_09 AC 6 ms
4,376 KB
testcase_10 AC 29 ms
5,524 KB
testcase_11 AC 19 ms
4,376 KB
testcase_12 AC 24 ms
5,672 KB
testcase_13 AC 64 ms
6,876 KB
testcase_14 AC 5 ms
4,380 KB
testcase_15 AC 49 ms
6,060 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 58 ms
6,736 KB
testcase_18 AC 4 ms
4,380 KB
testcase_19 AC 7 ms
4,860 KB
testcase_20 AC 5 ms
5,392 KB
testcase_21 AC 59 ms
6,484 KB
testcase_22 AC 5 ms
4,380 KB
testcase_23 AC 4 ms
4,376 KB
testcase_24 AC 10 ms
5,548 KB
testcase_25 AC 12 ms
4,968 KB
testcase_26 AC 8 ms
4,380 KB
testcase_27 AC 16 ms
5,132 KB
testcase_28 AC 38 ms
6,700 KB
testcase_29 AC 10 ms
6,788 KB
testcase_30 AC 24 ms
4,588 KB
testcase_31 AC 46 ms
7,208 KB
testcase_32 AC 77 ms
7,420 KB
testcase_33 AC 78 ms
7,316 KB
testcase_34 AC 83 ms
7,428 KB
testcase_35 AC 77 ms
7,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int H,W;
int A[1010][1010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int nex=1;
	cin>>H>>W;
	
	if(H%2==0) {
		FOR(y,H/2) FOR(x,W) A[y*2+x%2][x]=nex++;
		FOR(y,H/2) FOR(x,W) A[H-1-y*2-(x+W+1)%2][W-1-x]=nex++;
	}
	else if(W%2==0) {
		FOR(x,W/2) FOR(y,H) A[y][x*2+y%2]=nex++;
		FOR(x,W/2) FOR(y,H) A[H-1-y][W-1-x*2-(y+H+1)%2]=nex++;
	}
	else {
		FOR(y,H/2) FOR(x,W) A[y*2+x%2][x]=nex++;
		A[H-1][0]=nex;
		FOR(y,H/2) FOR(x,W) A[H-2-y*2-x%2][W-1-x]=W+nex++;
		int S=A[0][0]+A[0][1]+A[1][0]+A[1][1];
		for(x=1;x<W;x++) A[H-1][x]=S-A[H-1][x-1]-A[H-2][x]-A[H-2][x-1];
	}
	
	cout<<"Yes"<<endl;
	FOR(y,H) {
		FOR(x,W) cout<<A[y][x]<<" ";
		cout<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0