博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces441C_Valera and Tubes(暴力)
阅读量:4626 次
发布时间:2019-06-09

本文共 2791 字,大约阅读时间需要 9 分钟。

Valera and Tubes
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard 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 ≤ 3002 ≤ 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 integersxi1, 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.

Sample test(s)
input
3 3 3
output
3 1 1 1 2 1 33 2 1 2 2 2 33 3 1 3 2 3 3
input
2 3 1
output
6 1 1 1 2 1 3 2 3 2 2 2 1
Note

Picture for the first sample:

Picture for the second sample:

解题报告
让每一个人两个,剩下给第一个
#include 
#include
#include
using namespace std;int mmap[310][310];int main(){ int n,m,k; while(cin>>n>>m>>k) { int t=n*m-(k-1)*2; int x=1,y=1; printf("%d",t); while(t--) { printf(" %d %d",x,y); mmap[x][y]=1; if(y+1<=m&&!mmap[x][y+1]) { y++; } else if(y-1>=1&&!mmap[x][y-1]) y--; else x++; } k--; while(k--) { printf("\n2"); t=2; while(t--) { printf(" %d %d",x,y); mmap[x][y]=1; if(y+1<=m&&!mmap[x][y+1]) { y++; } else if(y-1>=1&&!mmap[x][y-1]) y--; else x++; } } printf("\n"); }}

转载于:https://www.cnblogs.com/ldxsuanfa/p/10821174.html

你可能感兴趣的文章
Java反射的应用 --- 内省
查看>>
163邮箱报错: 535 Error: authentication failed
查看>>
HttpClient工具类
查看>>
nginx基础知识小结
查看>>
基本排序算法——基数排序java实现
查看>>
equals
查看>>
序列化 pickle(重点) shelve json(重点)
查看>>
PHP之Trait详解
查看>>
dubbo配置
查看>>
阅读笔记5
查看>>
POJ2029:Get Many Persimmon Trees(DP)
查看>>
使用 Entity Framework Core 时,通过代码自动 Migration
查看>>
react native mask 绘制
查看>>
dataGridView的使用经验
查看>>
bzoj4447[Scoi2015]小凸解密码
查看>>
洛谷 - P2602 - 数字计数 - 数位dp
查看>>
数据结构 - 主席树
查看>>
Linux——下常用程序的代理服务器(proxy)配置
查看>>
初步接触LVS
查看>>
Linux——Ubuntu下Sublime Text 2的安装
查看>>