結果
問題 |
No.1974 2x2 Flipper
|
ユーザー |
![]() |
提出日時 | 2022-06-10 22:03:43 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,865 bytes |
コンパイル時間 | 579 ms |
コンパイル使用メモリ | 68,088 KB |
最終ジャッジ日時 | 2025-01-29 19:52:09 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 23 WA * 2 |
ソースコード
#include <iostream> using namespace std; int main(){ int i,j,h,w; cin >> h >> w; if(h==1){ cout << 0 << endl; for(i=0;i<w;i++) cout << 0 << " "; cout << endl; return 0; } if(w==1){ cout << 0 << endl; for(i=0;i<h;i++) cout << 0 << "\n"; return 0; } if(h&1 && w&1){ int ans = 0; if(h>=w){ cout << (w - 1)*w + (h - w)*(w - 1) << endl; for(i=0;i<w;i++){ for(j=0;j<w;j++){ if(i==j) cout << 0 << " "; else cout << 1 << " "; } cout << endl; } for(i=w;i<h;i++){ for(j=0;j<w - 1;j++){ cout << 1 << " "; } cout << 0 << " "; cout << endl; } }else{ for(i=0;i<h;i++){ for(j=0;j<h;j++){ if(i==j) cout << 0 << " "; else cout << 1 << " "; } for(j=h;j<w;j++){ if(i<h - 1) cout << 1 << " "; else cout << 0 << " "; } cout << "\n"; } cout << (h - 1)*h + (w - h)*(h - 1) << endl; } }else if(h&1){ cout << (h - 1)*w << endl; for(i=0;i<h - 1;i++){ for(j=0;j<w;j++) cout << 1 << " "; cout << endl; } for(i=0;i<w;i++) cout << 0 << " "; cout << endl; }else if(w&1){ cout << h*(w - 1) << endl; for(i=0;i<h;i++){ for(j=0;j<w - 1;j++) cout << 1 << " "; cout << 0 << "\n"; } }else{ cout << h*w << endl; for(i=0;i<h;i++){ for(j=0;j<w;j++) cout << 1 << " "; cout << endl; } } }