UVALive 6451:Tables(模拟 Grade D)
题意:模拟输出表格
思路:模拟……很暴力
代码:
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
using namespace std; int graph[][]; int main() {
int n;
while (scanf("%d", &n) != EOF) {
if (n == ) break;
memset(graph, , sizeof(graph)); int maxcol = ;
for (int i = ; i < n; i++){
int m;
scanf("%d", &m);
for (int j = ; j < m; j++) {
int row, col;
scanf("%d%d", &row, &col);
int bgc = ;
while (graph[i][bgc] != ) bgc++;
col = bgc+col;
row = i+row;
int id = (i+)*+bgc+;
maxcol = max(maxcol, col);
for (int r = i; r < row; r++) {
for (int c = bgc; c < col; c++) {
graph[r][c] = id;
}
}
}
} //for (int i = 0; i < n; i++) {
// for (int j = 0; j < maxcol; j++) {
// printf("%d ", graph[i][j]);
// }puts("");
//}puts(""); for (int i = ; i < maxcol; i++) {
printf(" --");
}puts(""); for (int i = ; graph[i][]; i++) {
//Line
printf("|");
for (int j = ; graph[i][j]; j++) {
if (graph[i][j] == (i+)*+j+) printf("%d", graph[i][j]);
else printf(" ");
if (graph[i][j] == graph[i][j+]) printf(" ");
else printf("|");
}puts(""); //Button
int store = ;
for (int j = ; graph[i][j]; j++) {
if (graph[i][j] == graph[i+][j]) store++;
else {
while (store) {
printf(" ");
store--;
}
printf(" --");
}
}puts("");
}
puts("");
}
return ;
}
UVALive 6451:Tables(模拟 Grade D)的更多相关文章
- UVALive 4222 Dance 模拟题
Dance 题目连接: https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&pag ...
- UVALive 3971 Assemble(模拟 + 二分)
UVALive 3971 题意:有b块钱.想要组装一台电脑,给出n个配件的种类,名字,价格,品质因子.若各种类配件各买一个,总价格<=b,求最差品质配件的最大品质因子. 思路: 求最大的最小值一 ...
- UVA 1594:Ducci Sequence (模拟 Grade E)
题意: 对于一个n元组(a0,a1,...),一次变换后变成(|a0-a1|,|a1-a2|,...) 问1000次变换以内是否存在循环. 思路: 模拟,map判重 代码: #include < ...
- UVA 1593: Alignment of Code(模拟 Grade D)
题意: 格式化代码.每个单词对齐,至少隔开一个空格. 思路: 模拟.求出每个单词最大长度,然后按行输出. 代码: #include <cstdio> #include <cstdli ...
- uva 177:Paper Folding(模拟 Grade D)
题目链接 题意:一张纸,每次从右往左对折.折好以后打开,让每个折痕都自然的呈90度.输出形状. 思路:模拟折……每次折想象成把一张纸分成了正面在下的一张和反面在上的一张.维护左边和方向,然后输出.细节 ...
- UVALive 3634 数据结构模拟
这题真是坑啊,题意不明,其实就是往桟里面压入空的set集合,所以之前的询问大小都是只有0,只有add的时候,才会产生新的占空间的集合 用stack和set直接进行模拟 #include <ios ...
- UVALive - 6440(模拟)
题目链接:https://vjudge.net/contest/241341#problem/G 题目大意:输入一个N,n次操作.对于第一种操作增加一个病人,告诉病人的t0,st0,r.第二种操作,在 ...
- UVA 1589:Xiangqi (模拟 Grade D)
题目: 象棋,黑棋只有将,红棋有帅车马炮.问是否死将. 思路: 对方将四个方向走一步,看看会不会被吃. 代码: 很难看……WA了很多发,还越界等等. #include <cstdio> # ...
- UVALive 3664:Guess(贪心 Grade E)
vj题目链接 题意: 有n (n<16345)个人,每个人有三个数(小于1000且最多两位小数点),表示答对对应题的得分.规定总分越高的人rank越高.总分相同,id小的rank高.现在知道ra ...
随机推荐
- issubclasss/type/isinstance/callable/super
issubclass() : 方法用于判断第一个参数是否是第二个参数的子子孙孙类. 语法:issubclass(sub, super) 检查sub类是否是 super 类的派生类 class A: p ...
- centos 服务器内存管理 服务于端口状态
du su /目录/ 查看改目录大小 ls -lht / 查看文件详情,显示文件大小(直观) df -h 查看系统内存占用情况 centos 版本 lsb_release -a cat /etc/i ...
- 以+scheduledTimerWithTimeInterval...的方式触发的timer,在滑动页面上的列表时,timer会暂定回调,为什么?如何解决?
这里强调一点:在主线程中以+scheduledTimerWithTimeInterval...的方式触发的timer默认是运行在NSDefaultRunLoopMode模式下的,当滑动页面上的列表时, ...
- 《Cracking the Coding Interview》——第4章:树和图——题目3
2014-03-19 03:34 题目:给定一个排好序的数组,设计算法将其转换为一棵二叉搜索树,要求树的高度最小. 解法:递归生成平衡二叉树,使左右子树的节点数尽量相等,所以对半开最好了.其实也可以生 ...
- DOS程序员手册(三)
56页 第4章DOS和BIOS接口 本章介绍了用户程序访问DOS内核和BIOS所提供的各种服务的方法.为了访问这 些服务,我们可以从任何编程语言中调用各个软件中断,这些中断便是我们在本 ...
- NGUI执行基本事件的原理
通常我们为对象附加一个脚本组件,脚本组件只要加此鼠标处理事件方法,这个对象就有了点击事件了: void OnClick() { Debug.Log("onclick"); } 可为 ...
- 孤荷凌寒自学python那些事第一天
孤荷凌寒自学python第一天 初识python (学习过程的完整录像分享链接在文末,手写笔记图片在文末) 一种编程语言,首先是它的语言的基本架构,python总体让人耳目一新: 今天其实只接触到了它 ...
- Android记事本开发04
昨天: 显式intent 隐身intent 今天: intentFilter 问题: 无法直接预览布局文件的效果.
- [poj] 3347 Kadj Square || 计算几何的“线段覆盖”
原题 多组数据,给出n个正方形的边长,使他们以45度角倾斜的情况下最靠左(在第一象限内),如图.求从上看能看到哪几个完整的正方形. 借鉴于https://www.cnblogs.com/Ritchie ...
- 【POJ 2387 Til the Cows Come Home】
Time Limit: 1000MSMemory Limit: 65536K Total Submissions: 59755Accepted: 20336 Description Bessie is ...