The simple graphical editor deals with a rectangular table M × N (1 ≤ M, N ≤ 250). Each pixel of the table has its colour. The picture is formed from this square pixels.

The problem is to write a program, which simulates an interactive work of the graphical editor.

Input

Input consists of the editor commands, one per line. Each command is represented by one Latin capital placed in the very beginning of the line. If the command supposes parameters, all the parameters will be given in the same line separated by space. As the parameters there may be: the coordinates of the pixel - two integers, the first one is the column number and belongs to 1 . . . M, the second one is the row number and belongs to 1 . . . N, the origin is in the upper left corner of the table; the colour - the Latin capital; file name - in MSDOS 8.3 format.

The editor deals with the following commands:

Output

Every time the command ‘S NAME’ meets, you should output the file name NAME and the current table, row by row. Each row is represented by a pixels’ colours series, see the output sample.

Errors: If as a command there will be a character different from I, C, L, V, H, K, F, S, X, the editor should ignore the whole line and pass to the next command.

In case of other errors the program behaviour is unpredictable.

Sample Input

I 5 6

L 2 3 A

S one.bmp

G 2 3 J

F 3 3 J

V 2 3 4 W

H 3 4 2 Z

S two.bmp

X

Sample Output

one.bmp

OOOOO

OOOOO

OAOOO

OOOOO

OOOOO

OOOOO

two.bmp

JJJJJ

JJZZJ

JWJJJ

JWJJJ

JJJJJ

JJJJJ

问题链接:UVA10267 Graphical Editor

问题简述:(略)

问题分析

这是一个模拟题,按照题意进行模拟即可。

程序说明

需要注意的是,输入的m和n分别表示列数和行数,x和y坐标与行列的关系。

题记:(略)

参考链接:(略)

AC的C++语言程序如下:

/* UVA10267 Graphical Editor */#include <bits/stdc++.h>using namespace std;const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};const int N = 250;
char graph[N + 1][N + 1];
int m, n;void draw(char cmd)
{int x1, y1, x2, y2;char c;if(cmd == 'V') {cin >> x1 >> y1 >> y2 >> c;x2 = x1;} else if(cmd == 'H')  {cin >> x1 >> x2 >> y1 >> c;y2 = y1;} else if(cmd == 'K')cin >> x1 >> y1 >> x2 >> y2 >> c;if(x2 < x1)swap(x1 , x2);if(y2 < y1)swap(y1 , y2);for(int i=y1; i<=y2; i++)for(int j= x1; j<=x2; j++)graph[i][j] = c;
}bool check(int x, int y)
{return 1 <= x && x <= n && 1 <= y && y <=  m;
}void dfs(int x, int y, char c)
{char color = graph[y][x];if(color  == c)return;graph[y][x] = c;for(int i =0;i <4;i++) {int nextx = x + dx[i];int nexty = y + dy[i];if(check(nexty , nextx) && graph[nexty][nextx] == color)dfs(nextx, nexty, c);}
}void command(char cmd)
{if(cmd == 'I') {scanf("%d%d", &m, &n);for(int i=1; i<=m; i++)for(int j=1; j<=n; j++)graph[j][i] = 'O';} else if(cmd == 'C') {for(int i=1; i<=m; i++)for(int j=1; j<=n; j++)graph[j][i] = 'O';} else if(cmd == 'L') {int x , y;char c;cin >> x >> y >> c;graph[y][x] = c;} else if(cmd == 'F') {int x, y;char c;cin >> x >> y >> c;dfs(x, y, c);} else if(cmd == 'S') {string s;cin >> s;cout << s << endl;for(int i=1; i<=n; i++) {for(int j = 1; j<=m; j++)printf("%c", graph[i][j]);printf("\n");}}
}int main()
{char cmd;while(~scanf("%c", &cmd) && cmd != 'X') {if(cmd == 'V' || cmd == 'H' || cmd == 'K')draw(cmd);elsecommand(cmd);}return 0;
}

UVA10267 Graphical Editor【模拟】相关推荐

  1. TYUT-A专题题解(一)

    TYUT-A专题题解(一) 01A Ad Hoc UVA353 LA5247 Pesky Palindromes[回文] - 海岛Blog - CSDN博客 UVA947 Master Mind He ...

  2. Competitive Programming 3题解

    题目一览: Competitive Programming 3: The New Lower Bound of Programming Contests(1) Competitive Programm ...

  3. ACM程序设计基础题解

    ACM水题一 HDU1262 寻找素数对[素数] - 海岛Blog - CSDN博客 HDU4548 美素数[水题] - 海岛Blog - CSDN博客 HDU2503 a/b + c/d[水题] - ...

  4. ACM程序设计基础(2)题解

    ACM水题二 CodeForces-1A Theatre Square[水题] - 海岛Blog - CSDN博客 AOJ0009 Prime Number[筛选法+前缀和] - 海岛Blog - C ...

  5. ICPC程序设计题解书籍系列之八:(美)斯基纳等:《挑战编程-程序设计竞赛训练手册》

    S书<挑战编程--程序设计竞赛训练手册>题目一览 1 Getting Started UVA100 POJ1207 HDU1032 The 3n + 1 problem[水题] - 海岛B ...

  6. Android 模拟TV遥控器物理按键

    在开发中想用代码模拟其他物理按键输入,这里用了shell 命令在程序运行时环境里模拟按键事件. private int volume = 0;private TimerTask timerTask;p ...

  7. 位域外部申明_(外部)域特定语言的完整指南

    位域外部申明 本指南将向您显示: 什么 :定义后,我们将研究19个DSL实例 原因 :使用DSL可以带来哪些具体好处? 方法 :我们将讨论构建DSL的不同方法以及成功的因素是什么 之后,您将获得一系列 ...

  8. (外部)特定领域语言的完整指南

    本指南将向您显示: 什么 :定义后,我们将研究19个DSL实例 原因 :使用DSL可以带来哪些具体好处? 如何 :我们将讨论构建DSL的不同方法以及成功的因素是什么 之后,您将获得一系列资源以学习更多 ...

  9. Eclipse 开源详细介绍

    Eclipse 生态系统非常大,有时候甚至达到了恐怖的地步.Eclipse Foundation 监管着大约 100 个项目,Galileo 只代表那些项目的一个缩影.Galileo 发行版系列展示 ...

最新文章

  1. java mp3 暂停,Java MP3播放器 - 使用jLayer播放,暂停和搜索不能正常工作
  2. ABAP SUBMIT 程序时带屏幕默认值
  3. 爱酷pro充电测试软件,iQOO 5 Pro续航、充电测试简报
  4. NKU两题简单题解析(递归分析与位运算技巧)
  5. 玩转oracle 11g(19):ora-00020和64位数据库安装32为plsql
  6. 一文搞清楚 Spark RDD到底是什么?
  7. AFN的简单二次封装
  8. 如何把局域网内不同数据库的两个表的数据进行传输?
  9. 如何理解和运用策略模式
  10. mac系统使用技巧链接汇总
  11. linux刷显卡bios版本,一种Linux系统下显卡刷新BIOS的方法与流程
  12. SSL证书以及其验证过程
  13. iOS滤镜实现之LOMO(美图秀秀经典LOMO)
  14. 亲试:darknet_yolov3批量测试图片并保存在自定义文件夹下与图片视频相互转换
  15. 计算机无法分盘,电脑如何分盘
  16. 神了!有人用一个项目把23种设计模式与六大原则融会贯通了
  17. pdf文件流转图片流方法(PDF文档所有页全部转换为图片 )
  18. 电商运营裂变新玩法—分销渠道系统模式
  19. ABAP WB01 BDC ”No batch input data for screen “ ”没有屏幕 的批输入数据“
  20. nginx二级域名配置阿里云免费SSL证书浏览器提示不安全

热门文章

  1. 开源linux远程桌面,10分钟配置自己的vnc [linux远程桌面]
  2. python爬虫审查元素_python爬虫3——获取审查元素(板野友美吧图片下载)
  3. JavaScript(五)对象
  4. Android:自定义BaseActivity基类
  5. SpringBoot-JPA删除不成功,只执行了查询语句
  6. Hadoop—SequenceFile文件的数据格式(1)
  7. 重新配对_Apple Watch配对失败的解决办法
  8. Spring Data JPA 条件查询 分页查询
  9. jmter测试jmeter参数化(必须掌握)
  10. python里 t_python中的“.T”操作