結果
| 問題 |
No.1974 2x2 Flipper
|
| コンテスト | |
| ユーザー |
Haa
|
| 提出日時 | 2022-06-10 22:12:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 94 ms / 2,000 ms |
| コード長 | 1,230 bytes |
| コンパイル時間 | 1,592 ms |
| コンパイル使用メモリ | 169,440 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-21 07:07:18 |
| 合計ジャッジ時間 | 5,012 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 25 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
#define REP(i,n) for(ll i=0;i<(n);i++)
#define ALL(v) v.begin(),v.end()
template<typename T> bool chmax(T &x, const T &y) {return (x<y)?(x=y,true):false;};
template<typename T> bool chmin(T &x, const T &y) {return (x>y)?(x=y,true):false;};
constexpr ll MOD=1000000007;
constexpr ll INF=2e18;
int main(){
int h, w; cin >> h >> w;
if(h%2==0&&w%2==0){
cout << h*w << endl;
REP(i,h)REP(j,w) cout << 1 << " \n"[j==w-1];
}
else if(h%2==1&&w%2==1){
cout << h*w-max(h,w) << endl;
REP(i,h)REP(j,w){
int f=1;
if(i==j)
f=0;
else if(i==h-1&&j>=h)
f=0;
else if(j==w-1&&i>=w)
f=0;
cout << f << " \n"[j==w-1];
}
}
else if(h%2==1){
cout << h*w-w << endl;
REP(i,h-1)REP(j,w) cout << 1 << " \n"[j==w-1];
REP(j,w) cout << 0 << " \n"[j==w-1];
}
else{
cout << h*w-h << endl;
REP(i,h){
REP(j,w-1) cout << 1 << " ";
cout << 0 << endl;
}
}
return 0;
}
Haa