【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

每个操作对与一个点来说变化是固定的。
因此可以不用对整个数组进行操作。
对于每个询问,遍历所有的操作。对输入的(x,y)进行相应的变换就好了。
数据之间有空行。

【代码】

 /*
ope=0 EX操作 交换a[x1][y1],a[x2][y2]
ope=1 DR操作 删除v中的行(无序)
ope=2 IR操作 在v中的位置插入空行(无顺序)
ope=3 DC操作 删除v中的列(无序)
ope=4 IC操作 插入v中的列(无序)
*/
#include <bits/stdc++.h>
using namespace std; int r,c;
int n; struct abc{
int ope;
vector<int> v;
}; abc temp; vector<abc> a; void input_mul(int ope){
temp.ope = ope;
temp.v.clear();
int cnt;cin >> cnt;
for (int j = 0;j < cnt;j++){
int x;
cin >> x;
temp.v.push_back(x);
}
a.push_back(temp);
} int main()
{
//freopen("/home/ccy/rush.txt","r",stdin);
ios::sync_with_stdio(0),cin.tie(0);
int kase = 0;
while (cin >> r >> c){
if (r==0 && c==0) break;
if (kase>0) cout<<endl;
cout<<"Spreadsheet #"<<++kase<<endl;
a.clear();
cin >> n;
for (int i = 0;i < n;i++){
string ts;
cin >> ts;
if (ts=="EX"){
temp.ope = 0;
temp.v.resize(4);
for (int j = 0;j < 4;j++) cin >> temp.v[j];
a.push_back(temp);
}
if (ts=="DR") input_mul(1);
if (ts=="IR") input_mul(2);
if (ts=="DC") input_mul(3);
if (ts=="IC") input_mul(4);
}
int q;
cin >> q;
while (q--){
int x,y,tx,ty;
cin >> x >> y;
tx = x,ty = y;
bool ok = 1;
for (int i = 0;i < (int) a.size();i++){
if (a[i].ope==0){
int x1,y1,x2,y2;
x1 = a[i].v[0],y1 = a[i].v[1];
x2 = a[i].v[2],y2 = a[i].v[3];
if (x1==x && y1 == y){
x = x2;y = y2;
}else
if (x2==x && y2==y){
x = x1;y = y1;
}
}
if (a[i].ope==1){
int subx = 0;
for (int rr:a[i].v){
if (rr<x) subx++;else if (rr==x) ok = 0;
}
x-=subx;
}
if (a[i].ope==2){
int addx = 0;
for (int rr:a[i].v){
if (rr<=x) addx++;
}
x+=addx;
}
if (a[i].ope==3){
int suby = 0;
for (int cc:a[i].v){
if (cc<y) suby++;else if (cc==y) ok = 0;
}
y-=suby;
}
if (a[i].ope==4){
int addy = 0;
for (int cc:a[i].v){
if (cc<=y) addy++;
}
y+=addy;
}
}
cout<<"Cell data in ("<<tx<<","<<ty<<") ";
if (ok==0){
cout<<"GONE"<<endl;
}else{
cout<<"moved to ("<<x<<","<<y<<")"<<endl;
}
} } return 0;
}

【例题 4-5 uva 512】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

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

  3. uva 512

    1. 问题 不知道怎么存储操作 看代码注释,else if等 2. 代码 #include <iostream> #include <stdio.h> #include < ...

  4. 踪电子表格中的单元格(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) 所示 ...

  5. UVA 215 Spreadsheet Calculator (模拟)

    模拟题.每个单元格有表达式就dfs,如果有环那么就不能解析,可能会重复访问到不能解析的单元格,丢set里或者数组判下重复. 这种题首先框架要对,变量名不要取的太乱,细节比较多,知道的库函数越多越容易写 ...

  6. 思维水题:UVa512-Spreadsheet Tracking

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

  7. D5 LCA 最近公共祖先

    第一题: POJ 1330 Nearest Common Ancestors POJ 1330 这个题可不是以1为根节点,不看题就会一直wa呀: 加一个找根节点的措施: #include<alg ...

  8. 算法笔记--斜率优化dp

    斜率优化是单调队列优化的推广 用单调队列维护递增的斜率 参考:https://www.cnblogs.com/ka200812/archive/2012/08/03/2621345.html 以例1举 ...

  9. 回文树&后缀自动机&后缀数组

    KMP,扩展KMP和Manacher就不写了,感觉没多大意思.   之前感觉后缀自动机简直可以解决一切,所以不怎么写后缀数组.   马拉车主要是通过对称中心解决问题,有的时候要通过回文串的边界解决问题 ...

随机推荐

  1. jQuery - 制作非缘勿扰页面特效

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. luogu2331 [SCOI2005]最大子矩阵

    题目大意 这里有一个n*m的矩阵,请你选出其中k个子矩阵,使得这个k个子矩阵分值之和最大.注意:选出的k个子矩阵不能相互重叠.1≤n≤100,1≤m≤2,1≤k≤10. 思路 #include < ...

  3. DirectFB编程【转】

    本文转载自:http://www.cnblogs.com/274914765qq/p/4358088.html DirectFB编程 一.简介 DirectFB是一个轻量级的提供硬件图形加速,输入设备 ...

  4. B2002 [Hnoi2010]Bounce 弹飞绵羊 分块

    原来做过,看大家都做这道题都热情高涨,沈爷爷debug这道题4天,作为告诉他这个题的人,我还有点不好意思...我自己也就做了一个小时. 其实这个题思路还好,就是维护每个点的出块次数和跳出块的位置,然后 ...

  5. PHPExcel 使用心得

    最近有个项目需要将数据导出成excel,以前都没接触过.便google一下知道了PHPExcel 这个据说很强大的类库. 写这个博文主要目的等同于做笔记 1首先看了下官方的文档.http://phpe ...

  6. Fisher 线性判别

    Multiplying both sides of this result by wT and adding w0, and making use of y(x)=wTx+w0 and  y(xΓ)= ...

  7. git的使用(转)

    git 配置文件 git的配置文件位置针对所有用户:/etc/gitconfig针对当前用户: -/.gitconfig 查看配置的方法 git config --list 修改配置的方法 git c ...

  8. html5 读取本地文件

    尊重原创:http://hushicai.com/2014/03/29/html5-du-qu-ben-di-wen-jian.html HTML5为我们提供了一种与本地文件系统交互的标准方式:Fil ...

  9. 浅谈自学Python之路(day3)

    今天的主要内容是: 撒 文件操作 对文件操作的流程: 打开文件,得到文件句柄并赋值给一个变量 通过句柄对文件进行操作 关闭文件 现有文件如下: tonghuazhen 听说白雪公主在逃跑 小红帽在担心 ...

  10. 一、SQL系列之~使用SQL语言导出数据及实现定时导出数据任务

    一般情况下,SQL数据库中带有导入与导出数据的直接按键操作,点击数据表所在的数据库--任务--导出/导入数据,根据导入/导出向导直接将数据导出即可. 但导出的数据格式多为Excel格式,如果需要导出的 ...