UVA512 - Spreadsheet Tracking
来源:互联网 发布:淘宝兼职招聘网 编辑:程序博客网 时间:2024/06/06 04:28
#include <stdio.h>#include <string.h>#include <string>#include <iostream>using namespace std;const int maxd=100;const int BIG=10000;int r,c,n,d[maxd][maxd], d2[maxd][maxd], ans[maxd][maxd], cols[maxd];void copy(char type, int p, int q){ if(type=='R'){ for(int i = 1 ; i <= c ; i++) d[p][i] = d2[q][i]; }else{ for(int i = 1; i<= r; i++){ d[i][p] = d2[i][q]; } }}void del(char type){ memcpy(d2,d,sizeof(d)); int cnt = (type =='R'? r : c), cnt2 = 0; for(int i =1 ; i <= cnt; i++){ if(!cols[i]) copy(type,++cnt2, i); } if(type == 'R') r = cnt2; else c= cnt2;}void ins(char type){ memcpy(d2, d, sizeof(d)); int cnt = type =='R'? r: c, cnt2 = 0; for( int i = 1;i <= cnt; i++){ if(cols[i]) copy(type, ++cnt2, 0); copy(type,++cnt2,i); } if(type=='R') r =cnt2; else c= cnt2;}int main(){ int r1,c1,r2,c2, q, kase=0; string cmd; memset(d, 0, sizeof(d)); while(scanf("%d%d%d",&r, &c ,&n)==3 &&r){ int r0= r,c0 =c; for(int i=1; i<=r; i++) for(int j =1; j<=c ; j++) d[i][j]=i*BIG+j; while(n--){ cin>>cmd; if(cmd[0]=='E'){ cin>>r1>>c1>>r2>>c2; int t=d[r1][c1];d[r1][c1]=d[r2][c2];d[r2][c2]=t; } else{ int a,x; cin>>a; memset(cols,0,sizeof(cols)); for(int i =0; i< a; i++){ cin>>x; cols[x] = 1; } if(cmd[0]=='D') del(cmd[1]); else ins(cmd[1]); } } memset(ans,0,sizeof(ans)); for(int i =1; i <= r ;i++) for(int j =1;j <= c; j++){ ans[d[i][j]/BIG][d[i][j]%BIG] =i*BIG+j; } kase&&(cout<<endl); cout<<"Spreadsheet #"<<++kase<<endl; cin>>q; while(q--){ cin>>r1>>c1; cout<<"Cell data in ("<<r1<<","<<c1<<") "; if(ans[r1][c1] == 0) cout<<"GONE\n"; else cout<<"moved to ("<<ans[r1][c1]/BIG<<","<<ans[r1][c1]%BIG<<")"<<endl; } } return 0;}
0 0
- UVA512 - Spreadsheet Tracking
- UVa512 - Spreadsheet Tracking
- UVALive5198 UVA512 Spreadsheet Tracking
- UVa512-Spreadsheet Tracking
- UVa512 Spreadsheet Tracking
- [UVA512]Spreadsheet Tracking[模拟][STL]
- 例题4-5 UVa512 Spreadsheet Tracking
- 思维水题:UVa512-Spreadsheet Tracking
- Spreadsheet Tracking
- Spreadsheet Tracking
- Spreadsheet Tracking
- Spreadsheet Tracking
- UVa_512 - Spreadsheet Tracking
- 512 - Spreadsheet Tracking
- 512 - Spreadsheet Tracking
- UVA - 512 Spreadsheet Tracking
- Uva - 512 - Spreadsheet Tracking
- UVA - 512 Spreadsheet Tracking
- Android网络编程概述
- 8张图理解Java
- 温故而知新-java排序与二分查找
- iOS 通知观察者的被调函数不一定运行在主线程
- 兰顿蚂蚁—题解
- UVA512 - Spreadsheet Tracking
- 100-200中的素数
- 提升windows权限的函数
- Caused by:org.hibernate.HibernateException:Unable to make JDBC Connection
- 调用graph api上传图片到facebook
- 电话语音状态识别
- #1123 : 好配对
- Java中如何不用中间变量来使两个变量交换值
- linux awk命令详解