Spreadsheet Tracking 

Data in spreadsheets are stored in cells, which are organized in rows (r) and columns (c). Some operations on spreadsheets can be applied to single cells (r,c), while others can be applied to entire rows or columns. Typical cell operations include inserting and deleting rows or columns and exchanging cell contents.

Some spreadsheets allow users to mark
collections of rows or columns for deletion, so the entire collection
can be deleted at once. Some (unusual) spreadsheets allow users to mark
collections of rows or columns for insertions too. Issuing an insertion
command results in new rows or columns being inserted before each of the
marked rows or columns. Suppose, for example, the user marks rows 1 and
5 of the spreadsheet on the left for deletion. The spreadsheet then
shrinks to the one on the right.

If the user subsequently marks columns 3, 6, 7, and 9 for deletion, the spreadsheet shrinks to this.

1 2 3 4 5
1 2 24 8 22 16
2 18 19 21 22 25
3 24 25 67 22 71
4 16 12 10 22 58
5 33 34 36 22 40

If the user marks rows 2, 3 and 5 for insertion, the spreadsheet grows
to the one on the left. If the user then marks column 3 for insertion,
the spreadsheet grows to the one in the middle. Finally, if the user
exchanges the contents of cell (1,2) and cell (6,5), the spreadsheet
looks like the one on the right.

You must write tracking software that determines the final location of
data in spreadsheets that result from row, column, and exchange
operations similar to the ones illustrated here.

Input

The input consists of a sequence of spreadsheets, operations on those
spreadsheets, and queries about them. Each spreadsheet definition begins
with a pair of integers specifying its initial number of rows (
r) and columns (
c), followed by an integer specifying the number (
n) of spreadsheet operations. Row and column labeling begins
with 1. The maximum number of rows or columns of each spreadsheet is
limited to 50. The following n lines specify the desired operations.

An operation to exchange the contents of cell (r1, c1) with the contents of cell (r2, c2) is given by:

EXr1c1r2c2

The four insert and delete commands--DC (delete columns), DR (delete rows), IC (insert columns), and IR (insert rows) are given by:

<command> Ax1x2xA

where <command> is one of the four commands; A is a positive integer less than 10, and
are the labels of the columns or rows to be deleted or inserted before.
For each insert and delete command, the order of the rows or columns in
the command has no significance. Within a single delete or insert
command, labels will be unique.

The operations are
followed by an integer which is the number of queries for the
spreadsheet. Each query consists of positive integers r and c,
representing the row and column number of a cell in the original
spreadsheet. For each query, your program must determine the current
location of the data that was originally in cell (r, c). The end of input is indicated by a row consisting of a pair of zeros for the spreadsheet dimensions.

Output

For each spreadsheet, your program must output its sequence number
(starting at 1). For each query, your program must output the original
cell location followed by the final location of the data or the word GONE
if the contents of the original cell location were destroyed as a
result of the operations. Separate output from different spreadsheets
with a blank line.

The data file will not contain a sequence of commands that will cause the spreadsheet to exceed the maximum size.

Sample Input

7 9
5
DR 2 1 5
DC 4 3 6 7 9
IC 1 3
IR 2 2 4
EX 1 2 6 5
4
4 8
5 5
7 8
6 5
0 0

Sample Output

Spreadsheet #1
Cell data in (4,8) moved to (4,6)
Cell data in (5,5) GONE
Cell data in (7,8) moved to (7,6)
Cell data in (6,5) moved to (1,2)
 #include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <string>
#include <vector>
using namespace std;
const double EXP=1e-;
const double PI=acos(-1.0);
const int INF=0x7fffffff;
const int MS=;
const int MAX=; struct command
{
char c[];
int r1,c1,r2,c2;
int n;
int x[MS];
}cmd[MAX];
int R,C,N,Q;
int find(int &r0,int &c0)
{
for(int i=;i<N;i++)
{
if(cmd[i].c[]=='E')
{
if(cmd[i].r1==r0&&cmd[i].c1==c0)
{
r0=cmd[i].r2;
c0=cmd[i].c2;
}
else if(cmd[i].r2==r0&&cmd[i].c2==c0)
{
r0=cmd[i].r1;
c0=cmd[i].c1;
}
}
else
{
int dr=,dc=;
for(int j=;j<cmd[i].n;j++)
{
int x=cmd[i].x[j];
if(cmd[i].c[]=='I')
{
if(cmd[i].c[]=='R'&&x<=r0)
dr++;
if(cmd[i].c[]=='C'&&x<=c0)
dc++;
}
else
{
if(cmd[i].c[]=='R'&&x==r0)
return ;
if(cmd[i].c[]=='C'&&x==c0)
return ;
if(cmd[i].c[]=='R'&&x<r0)
dr--;
if(cmd[i].c[]=='C'&&x<c0)
dc--;
}
}
r0+=dr;
c0+=dc;
}
}
return ;
}
int main()
{
int r0,c0,kase=;
while(scanf("%d%d%d",&R,&C,&N)==&&R)
{
for(int i=;i<N;i++)
{
scanf("%s",cmd[i].c);
if(cmd[i].c[]=='E')
scanf("%d%d%d%d",&cmd[i].r1,&cmd[i].c1,&cmd[i].r2,&cmd[i].c2);
else
{
scanf("%d",&cmd[i].n);
for(int j=;j<cmd[i].n;j++)
scanf("%d",&cmd[i].x[j]);
}
}
if(kase>)
printf("\n");
printf("Spreadsheet #%d\n",++kase);
scanf("%d",&Q);
while(Q--)
{
scanf("%d%d",&r0,&c0);
printf("Cell data in (%d,%d) ",r0,c0);
if(!find(r0,c0))
printf("GONE\n");
else
printf("moved to (%d,%d)\n",r0,c0);
}
}
return ;
}

Spreadsheet Tracking的更多相关文章

  1. Uva - 512 - Spreadsheet Tracking

    Data in spreadsheets are stored in cells, which are organized in rows (r) and columns (c). Some oper ...

  2. 踪电子表格中的单元格(Spreadsheet Tracking, ACM/ICPC World Finals 1997, UVa512)

    有一个r行c列(1≤r,c≤50)的电子表格,行从上到下编号为1-r,列从左到右编号为1 -c.如图4-2(a)所示,如果先删除第1.5行,然后删除第3, 6, 7, 9列,结果如图4-2(b) 所示 ...

  3. 【例题 4-5 uva 512】Spreadsheet Tracking

    [链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 每个操作对与一个点来说变化是固定的. 因此可以不用对整个数组进行操作. 对于每个询问,遍历所有的操作.对输入的(x,y)进行相应的变 ...

  4. 思维水题:UVa512-Spreadsheet Tracking

    Spreadsheet Tracking Data in spreadsheets are stored in cells, which are organized in rows (r) and c ...

  5. Metaio在Unity3D中报错 Start: failed to load tracking configuration: TrackingConfigGenerated.xml 解决方法

    报错:Start: failed to load tracking configuration: TrackingConfigGenerated.xml Start: failed to load t ...

  6. SharePoint 2010 Survey的Export to Spreadsheet功能怎么不见了?

    背景信息: 最近用户报了一个问题,说他创建的Survey里将结果导出成Excel文件(Export to spreadsheet)的按钮不见了. 原因排查: 正常情况下,这个功能只存在于SharePo ...

  7. SQL Server 更改跟踪(Chang Tracking)监控表数据

    一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 主要区别与对比(Compare) 实现监控表数据步骤(Process) 参考文献(Refere ...

  8. Computer Vision: OpenCV, Feature Tracking, and Beyond--From <<Make Things See>> by Greg

    In the 1960s, the legendary Stanford artificial intelligence pioneer, John McCarthy, famously gave a ...

  9. undefined reference to `Spreadsheet::staticMetaObject'

    <C++ GUI Qt 4 编程>学习 一.遇到的问题 在学完第4章后,Spreasheet程序也已经写好了.在用 FindDialog 搜索时发现没有效果. 二.解决过程 调试跟踪代码, ...

随机推荐

  1. HDU5634 Rikka with Phi 线段树

    // HDU5634 Rikka with Phi 线段树 // 思路:操作1的时候,判断一下当前区间是不是每个数都相等,在每个数相等的区间上操作.相当于lazy,不必更新到底. #include & ...

  2. BootStrap入门教程 (三) :可重用组件(按钮,导航,标签,徽章,排版,缩略图,提醒,进度条,杂项)

    上讲回顾:Bootstrap的基础CSS(Base CSS)提供了优雅,一致的多种基础Html页面要素,包括排版,表格,表单,按钮等,能够满足前端工程师的基本要素需求. Bootstrap作为完整的前 ...

  3. Hadoop 2.6.0 POM.xml

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...

  4. RabbitMQ (四) 路由选择 (Routing) -摘自网络

    本篇博客我们准备给日志系统添加新的特性,让日志接收者能够订阅部分消息.例如,我们可以仅仅将致命的错误写入日志文件,然而仍然在控制面板上打印出所有的其他类型的日志消息. 1.绑定(Bindings) 在 ...

  5. Xshell异常断开

    这可能是由于 SSH 超时断开连接 导致的!可以这样做...修改/etc/ssh/sshd_config文件,找到 ClientAliveInterval 0和ClientAliveCountMax ...

  6. ecstore 后台登陆跳转到 api失败,中心请求网店API失败

    解决过程没有具体参与,官方解决后回复的邮件,可以参考一下: 后台登陆错误图:   商派解决方法邮件:   特别注意:这个错误提示有时候也跟ecstore的nginx服务器伪静态有关,具体参考: htt ...

  7. DATASNAP为支持FIREDAC而增加的远程方法的数据类型TFDJSONDataSets

    前面的博客提到用FIREDAC全面替代COM那一套东西:DATAPROVIDER,OLEVARIANT,CLIENTDATASET,DBEXPRESS... 显然,DATASNAP的远程方法必须增加对 ...

  8. HDU 5441 Travel (并查集+数学+计数)

    题意:给你一个带权的无向图,然后q(q≤5000)次询问,问有多少对城市(城市对(u,v)与(v,u)算不同的城市对,而且u≠v)之间的边的长度不超过d(如果城市u到城市v途经城市w, 那么需要城市u ...

  9. 关于block以及__bridge的一些笔记

    问题概要 _block是否是一个OC对象? __bridge相关. _block是否是一个OC对象? 结论 一般来说,block可以看做一个OC对象,但是在编译器底层,block又可以被细分为bloc ...

  10. EasyUI datetimebox设置默认值为当前时间

    设置value="${notices.release_time}" <input class="easyui-validatebox easyui-datetime ...