CF441C.Valera and Tubes

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Valera has got a rectangle table consisting of nn rows and mm 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 xx and column yy by a pair of integers (x,y)(x,y) .

Valera wants to place exactly kk tubes on his rectangle table. A tube is such sequence of table cells (x1,y1)(x_{1},y_{1}) , (x2,y2)(x_{2},y_{2}) , ...... , (xr,yr)(x_{r},y_{r}) , that:

  • r>=2r>=2 ;
  • for any integer ii (1<=i<=r1)(1<=i<=r-1) the following equation xixi+1+yiyi+1=1|x_{i}-x_{i+1}|+|y_{i}-y_{i+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 kk tubes on his rectangle table in a fancy manner.

输入格式

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

输出格式

Print kk lines. In the ii -th line print the description of the ii -th tube: first print integer rir_{i} (the number of tube cells), then print 2ri2r_{i} integers xi1,yi1,xi2,yi2,...,xiri,yirix_{i1},y_{i1},x_{i2},y_{i2},...,x_{iri},y_{iri} (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.

输入输出样例

  • 输入#1

    3 3 3
    

    输出#1

    3 1 1 1 2 1 3
    3 2 1 2 2 2 3
    3 3 1 3 2 3 3
    
  • 输入#2

    2 3 1
    

    输出#2

    6 1 1 1 2 1 3 2 3 2 2 2 1
    

说明/提示

Picture for the first sample:

Picture for the second sample:

首页