結果

問題 No.1974 2x2 Flipper
ユーザー 沙耶花沙耶花
提出日時 2022-06-10 21:47:32
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 895 bytes
コンパイル時間 4,458 ms
コンパイル使用メモリ 263,752 KB
実行使用メモリ 7,660 KB
最終ジャッジ日時 2023-10-21 05:55:55
合計ジャッジ時間 7,940 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 10 ms
4,348 KB
testcase_02 AC 3 ms
4,348 KB
testcase_03 AC 49 ms
6,312 KB
testcase_04 AC 23 ms
4,884 KB
testcase_05 AC 14 ms
4,388 KB
testcase_06 AC 34 ms
5,544 KB
testcase_07 AC 25 ms
4,888 KB
testcase_08 AC 6 ms
4,348 KB
testcase_09 AC 37 ms
5,644 KB
testcase_10 AC 6 ms
4,348 KB
testcase_11 AC 29 ms
5,184 KB
testcase_12 AC 49 ms
6,304 KB
testcase_13 AC 29 ms
5,272 KB
testcase_14 AC 18 ms
4,640 KB
testcase_15 AC 60 ms
6,736 KB
testcase_16 AC 6 ms
4,348 KB
testcase_17 AC 42 ms
5,852 KB
testcase_18 AC 6 ms
4,348 KB
testcase_19 AC 7 ms
4,348 KB
testcase_20 AC 21 ms
4,852 KB
testcase_21 AC 72 ms
7,660 KB
testcase_22 AC 77 ms
7,656 KB
testcase_23 AC 72 ms
7,660 KB
testcase_24 AC 76 ms
7,656 KB
testcase_25 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint1000000007;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

int main(){
	int h,w;
	cin>>h>>w;
	
	vector a(h,vector<int>(w,0));
	rep(i,h){
		rep(j,w){
			if(a[i][j]==1)continue;
			if(i+1<h&&j+1<w){
				rep(k,2){
					rep(l,2){
						a[i+k][j+l] = 1;
					}
				}
			}
		}
	}
	
	if(h>=3&&w>=3&&h%2==1&&w%2==1){
		a.assign(h,vector<int>(w,1));
		if(h>=w){
			rep(i,h){
				if(i<w){
					a[i][i] = 0;
				}
				else{
					a[i][w-1] = 0;
				}
			}
		}
		else{
			rep(i,w){
				if(i<h){
					a[i][i] = 0;
				}
				else{
					a[h-1][i] = 0;
				}
			}
		}
	}
	
	int ans = 0;
	rep(i,h){
		rep(j,w){
			ans += a[i][j];
		}
	}
	cout<<ans<<endl;
	rep(i,h){
		rep(j,w){
			if(j!=0)cout<<' ';
			cout<<a[i][j];
		}
		cout<<endl;
	}
	
    return 0;
}
0