結果

問題 No.3744 XY Tiling
コンテスト
ユーザー sig_256
提出日時 2026-09-19 15:34:09
言語 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,747 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,085 ms
コンパイル使用メモリ 176,512 KB
実行使用メモリ 10,044 KB
最終ジャッジ日時 2026-09-19 15:34:26
合計ジャッジ時間 4,641 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
サブタスク 配点 結果
部分点 60 % AC * 9 WA * 10
満点 40 % AC * 33 WA * 27
合計 5 * 0% = 0 点
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <array>
#include <utility>

using std::cin;
using std::cout;
using std::clog;
using std::vector;
using std::array;
using std::swap;

#include <cstdint>

using u8 = std::uint8_t;
using u16 = std::uint16_t;
using u32 = std::uint32_t;
using u64 = std::uint64_t;
using i8 = std::int8_t;
using i16 = std::int16_t;
using i32 = std::int32_t;
using i64 = std::int64_t;

u32 C;
vector<array<u32, 6>> ans;
/*
x2x3x4x5x6
_222222222
__x3x4x5x6
___3333333
____x4x4x4
_____44444

111111
222222
232323
333333
444444
*/

void solve_1 (u32 H, u32 W) { // Wがeven
	C = W / 2 + 1;
	for (u32 h = 0; h < H; ++h) {
		for (u32 w = 0; w < W; w += 2) {
			ans.push_back(array<u32, 6>{
				h, w, w / 2,
				h, w + 1, w / 2 + 1
			});
		}
	}
}
void solve_2 (u32 H, u32 W) { // Wがeven
	C = 4;
	for (u32 w = 0; w < W; ++w) {
		ans.push_back(array<u32, 6>{
			0, w, 0,
			1, w, 1
		});
	}
	for (u32 h = 2; h < H - 2; ++h) {
		for (u32 w = 0; w < W; w += 2) {
			ans.push_back(array<u32, 6>{
				h, w, 1,
				h, w + 1, 2
			});
		}
	}
	for (u32 w = 0; w < W; ++w) {
		ans.push_back(array<u32, 6>{
			H - 2, w, 2,
			H - 1, w, 3
		});
	}
}

int main() {
	u32 H, W;
	cin >> H >> W;
	bool swapping = false;
	if (H > W) swap(H, W), swapping = true;
	if (H < 5) {
		if (H % 2 == 0) {
			swapping = !swapping;
			solve_1(W, H);
		} else if (W % 2 == 0) {
			solve_1(H, W);
		} else {
			swapping = !swapping;
			solve_1(W, H);
		}
	} else {
		if (W % 2 == 0) {
			solve_2(H, W);
		} else {
			swapping = !swapping;
			solve_2(W, H);
		}
	}
	cout << C << '\n';
	for (auto& a : ans) {
		if (swapping) swap(a[0], a[1]), swap(a[3], a[4]);
		for (u32 i = 0; i < 6; ++i) {
			cout << a[i] + 1 << (i == 5 ? '\n' : ' ');
		}
	}
	return 0;
}

0