結果

問題 No.3744 XY Tiling
コンテスト
ユーザー cacampu
提出日時 2026-09-19 17:50:51
言語 Rust
(1.97.1 + proconio + num + itertools + ACL)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
RE  
実行時間 -
コード長 2,415 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 751 ms
コンパイル使用メモリ 182,428 KB
実行使用メモリ 6,528 KB
最終ジャッジ日時 2026-09-19 17:51:09
合計ジャッジ時間 4,473 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
部分点 60 % AC * 19
満点 40 % AC * 46 WA * 6 RE * 8
合計 5 * 60% = 300 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

use std::mem::swap;

use proconio::input;

fn main() {
    input! {
        mut h: usize,
        mut w: usize,
    }
    let mut trans = false;
    if h > w {
        swap(&mut h, &mut w);
        trans = true;
    }
    let mut color = 3;
    let mut dominos = vec![];
    if h == 1 {
        color = w / 2 + 1;
        for j in (0..w).step_by(2) {
            dominos.push([0, j, (j + 1) / 2, 0, j + 1, (j + 2) / 2]);
        }
    } else if h <= 4 {
        color = h / 2 + 1;
        let mut c = vec![vec![0; w]; h];
        for i in 0..h {
            for j in 0..w {
                c[i][j] = (i + 1) / 2;
            }
        }
        for i in (0..h).step_by(2) {
            for j in 0..w {
                dominos.push([i, j, c[i][j], i + 1, j, c[i + 1][j]]);
            }
        }
    } else if h >= 4 && w >= 6 {
        for i in 0..h {
            dominos.push([i, 0, 2, i, 1, 0]);
        }
        for i in 2..h - 2 {
            dominos.push([i, 2, 0, i, 3, 1]);
        }
        for i in 2..h {
            dominos.push([i, w - 2, 0, i, w - 1, 1]);
        }
        for j in 2..w {
            dominos.push([0, j, 0, 1, j, 1]);
        }
        for j in 2..w - 2 {
            dominos.push([h - 2, j, 1, h - 1, j, 0]);
        }
        if h % 2 == 0 {
            for i in (2..h - 2).step_by(2) {
                for j in 4..w - 2 {
                    dominos.push([i, j, 0, i + 1, j, 1]);
                }
            }
        } else if h >= 6 {
            for j in 4..w - 2 {
                dominos.push([2, j, 1, 3, j, 0]);
            }
            for j in (4..w - 2).step_by(2) {
                for i in 4..h - 2 {
                    dominos.push([i, j, 0, i, j + 1, 1]);
                }
            }
        }
    }
    output(&dominos, color, trans);
}

fn output(dominos: &[[usize; 6]], color: usize, trans: bool) {
    println!("{}", color);
    for &[x, y, c, x2, y2, c2] in dominos {
        if !trans {
            println!(
                "{} {} {} {} {} {}",
                x + 1,
                y + 1,
                c + 1,
                x2 + 1,
                y2 + 1,
                c2 + 1
            );
        } else {
            println!(
                "{} {} {} {} {} {}",
                y + 1,
                x + 1,
                c + 1,
                y2 + 1,
                x2 + 1,
                c2 + 1
            );
        }
    }
}

0