結果
問題 | No.2112 All 2x2 are Equal |
ユーザー |
![]() |
提出日時 | 2022-10-28 22:02:55 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 948 bytes |
コンパイル時間 | 1,470 ms |
コンパイル使用メモリ | 172,196 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-07-06 01:11:59 |
合計ジャッジ時間 | 6,134 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 34 |
ソースコード
#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(int 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=998244353;constexpr ll INF=2e18;int main(){int h, w; cin >> h >> w;bool f=0;if(h%2==1&&w%2==0){f=1;swap(h,w);}VVI ans(h+1,VI(w));int l=1, r=h*w;REP(i,(h+1)/2){REP(j,w){int x=j%2==1;int y=j%2==0;ans[i*2+x][j]=l++;ans[i*2+y][j]=r--;}}cout << "Yes" << endl;if(!f)REP(i,h)REP(j,w) cout << ans[i][j] << " \n"[j==w-1];elseREP(i,w)REP(j,h) cout << ans[j][i] << " \n"[j==h-1];return 0;}