結果

問題 No.2112 All 2x2 are Equal
ユーザー ruthen71ruthen71
提出日時 2022-10-28 22:24:30
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 751 bytes
コンパイル時間 2,265 ms
コンパイル使用メモリ 205,596 KB
実行使用メモリ 7,168 KB
最終ジャッジ日時 2024-07-06 01:35:30
合計ジャッジ時間 6,929 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 34
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#ifdef _RUTHEN
#include <debug.hpp>
#else
#define show(...) true
#endif

using ll = long long;
#define rep(i, n) for (int i = 0; i < (n); i++)
template <class T> using V = vector<T>;

void solve() {
    int H, W;
    cin >> H >> W;
    V<V<int>> ans(H, V<int>(W));
    int c = 1;
    rep(i, H) {
        if (i % 2 == 0) {
            rep(j, W) ans[i][j] = c++;
        } else {
            rep(j, W) ans[i][W - 1 - j] = c++;
        }
    }
    show(ans);
    cout << "Yes" << '\n';
    rep(i, H) rep(j, W) cout << (j % 2 == 1 ? ans[H - 1 - i][j] : ans[i][j]) << " \n"[j == W - 1];
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int tt = 1;
    while (tt--) solve();
    return 0;
}
0