Codeforces - 441C-Valera and Tubes

解决如何在 n×m 的矩阵中以特定方式放置 k 条长度至少为 2 的互不相交的管子,使得每个单元格都属于某条管子的问题。给定 n, m, k 的值,需要输出每条管子的坐标序列。已知至少存在一种解决方案。" 79734879,7495178,Python编程:实践汽车租赁与电影票价格模拟,"['Python', '控制结构', '条件语句', '循环', '函数']
摘要由CSDN通过智能技术生成

Codeforces - 441C-Valera and Tubes

原题链接:http://codeforces.com/problemset/problem/441/C

C. Valera and Tubes
time limit per test1 second
memory limit per test256 megabytes
inputstandard input
outputstandard output
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).

Valera wants to place exactly k tubes on his rectangle table. A tube is such sequence of table cells (x1, y1), (x2, y2), …, (xr, yr), that:

r ≥ 2;
for any integer i (1 ≤ i ≤ r - 1) the following equation |xi - xi + 1| + |yi - yi + 1| = 1 holds;
each table cell, which belongs to the tube, must occur exactly once in the sequence.
Valera thinks that the tubes are arranged in a fancy manner if the following conditions are fulfilled:

no pair of tubes has common cells;
each cell of the table belongs to some tube.
Help Valera to arrange k tubes on his rectangle table in a fancy manner.

Input
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.

Output
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, …, xiri, yiri (the sequence of table cells).

If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution exists.

Examples
inpu

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值