結果

問題 No.3744 XY Tiling
コンテスト
ユーザー 👑 kencho
提出日時 2026-07-27 12:57:47
言語 C++23(gcc16)
(gcc 16.1.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,384 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,354 ms
コンパイル使用メモリ 351,320 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-19 12:37:52
合計ジャッジ時間 5,779 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
部分点 60 % AC * 9 WA * 10
満点 40 % AC * 28 WA * 32
合計 5 * 0% = 0 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int h, w;
    cin >> h >> w;

    if (h == 2 && w == 2) {
        cout << "2\n";
        cout << "1 1 1 1 2 2\n";
        cout << "2 2 2 2 1 1\n";
        return 0;
    }
    if (h == 4 && w == 1) {
        cout << "3\n";
        cout << "1 1 2 2 1 1\n";
        cout << "3 1 1 4 1 3\n";
        return 0;
    }

    bool use_rows;
    if (h % 2 == 0 && w % 2 == 0) {
        use_rows = h <= w;
    } else {
        use_rows = h % 2 == 0;
    }

    int length = use_rows ? h : w;
    cout << length / 2 + 1 << '\n';

    if (use_rows) {
        for (int r = 0; r < h; r += 2) {
            int upper_color = r / 2 + 1;
            int lower_color = upper_color + 1;
            for (int c = 0; c < w; ++c) {
                cout << r + 1 << ' ' << c + 1 << ' ' << upper_color << ' '
                     << r + 2 << ' ' << c + 1 << ' ' << lower_color << '\n';
            }
        }
    } else {
        for (int c = 0; c < w; c += 2) {
            int left_color = c / 2 + 1;
            int right_color = left_color + 1;
            for (int r = 0; r < h; ++r) {
                cout << r + 1 << ' ' << c + 1 << ' ' << left_color << ' '
                     << r + 1 << ' ' << c + 2 << ' ' << right_color << '\n';
            }
        }
    }
    return 0;
}
0