結果
| 問題 |
No.1974 2x2 Flipper
|
| コンテスト | |
| ユーザー |
srjywrdnprkt
|
| 提出日時 | 2023-05-14 08:33:50 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 90 ms / 2,000 ms |
| コード長 | 1,517 bytes |
| コンパイル時間 | 1,002 ms |
| コンパイル使用メモリ | 109,596 KB |
| 最終ジャッジ日時 | 2025-02-13 00:26:42 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 |
ソースコード
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <iomanip>
#include <queue>
#include <algorithm>
#include <numeric>
#include <deque>
#include <complex>
#include <cassert>
using namespace std;
using ll = long long;
int main(){
int H, W;
cin >> H >> W;
vector<vector<int>> ans(H, vector<int>(W));
if (H == 1 || W == 1){
cout << 0 << endl;
}
else if (H % 2 == 0 && W % 2 == 0){
cout << H*W << endl;
for (int i=0; i<H; i++){
for (int j=0; j<W; j++) ans[i][j] = 1;
}
}
else if (H % 2 == 0 && W % 2 == 1){
cout << H*(W-1) << endl;
for (int i=0; i<H; i++){
for (int j=0; j<W-1; j++) ans[i][j] = 1;
}
}
else if (H % 2 == 1 && W % 2 == 0){
cout << (H-1)*W << endl;
for (int i=0; i<H-1; i++){
for (int j=0; j<W; j++) ans[i][j] = 1;
}
}
else{
for (int i=0; i<H; i++){
for (int j=0; j<W; j++) ans[i][j] = 1;
}
if (H > W){
cout << H * (W-1) << endl;
for (int i=0; i<W; i++) ans[i][i] = 0;
for (int i=W; i<H; i++) ans[i][W-1] = 0;
}
else{
cout << (H-1) * W << endl;
for (int i=0; i<H; i++) ans[i][i] = 0;
for (int i=H; i<W; i++) ans[H-1][i] = 0;
}
}
for (int i=0; i<H; i++){
for (int j=0; j<W; j++) cout << ans[i][j] << " ";
cout << endl;
}
return 0;
}
srjywrdnprkt