結果
問題 |
No.1974 2x2 Flipper
|
ユーザー |
![]() |
提出日時 | 2022-11-06 12:59:41 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 48 ms / 2,000 ms |
コード長 | 1,897 bytes |
コンパイル時間 | 1,685 ms |
コンパイル使用メモリ | 167,724 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-07-20 03:00:37 |
合計ジャッジ時間 | 4,807 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
#include <bits/stdc++.h> using namespace std; int max(int a,int b){ if(a>b){ return a; } return b; } int main(){ int H,W; scanf("%d %d",&H,&W); if(H % 2 == 1 && W % 2 == 1){ printf("%d\n",H*W - max(H,W)); } if(H % 2 == 0 && W % 2 == 1){ printf("%d\n",H*W - H); } if(H % 2 == 1 && W % 2 == 0){ printf("%d\n",H*W - W); } if(H % 2 == 0 && W % 2 == 0){ printf("%d\n",H*W); } if(H % 2 == 1 && W % 2 == 1 && H < W){ for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(i == j || (i == H-1 && H-1 <= j)){ printf("0 "); } else { printf("1 "); } } printf("\n"); } } if(H % 2 == 1 && W % 2 == 1 && H >= W){ for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(i == j || (j == W-1 && W-1 <= i)){ printf("0 "); } else { printf("1 "); } } printf("\n"); } } if(H % 2 == 1 && W % 2 == 0){ for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(i == H-1){ printf("0 "); } else { printf("1 "); } } printf("\n"); } } if(H % 2 == 0 && W % 2 == 1){ for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ if(j == W-1){ printf("0 "); } else { printf("1 "); } } printf("\n"); } } if(H % 2 == 0 && W % 2 == 0){ for(int i=0;i<H;i++){ for(int j=0;j<W;j++){ printf("1 "); } printf("\n"); } } }