UVA - 512 Spreadsheet Tracking
生活随笔
收集整理的這篇文章主要介紹了
UVA - 512 Spreadsheet Tracking
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
Spreadsheet Tracking
?UVA - 512?
題目傳送門
紫書第二個思路十分巧妙,能用很少的代碼解出此題。
AC代碼:
#include <cstdio> #include <iostream> #include <algorithm> #include <cmath> #include <cstdlib> #include <cstring> #include <map> #include <stack> #include <queue> #include <vector> #include <bitset> #include <set> #include <utility> #include <sstream> #include <iomanip> using namespace std; typedef long long ll; typedef unsigned long long ull; #define inf 0x3f3f3f3f #define rep(i,l,r) for(int i=l;i<=r;i++) #define lep(i,l,r) for(int i=l;i>=r;i--) #define ms(arr) memset(arr,0,sizeof(arr)) //priority_queue<int,vector<int> ,greater<int> >q; const int maxn = (int)1e5 + 5; const ll mod = 1e9+7; int t1; struct node {string idx;int n;int arr[15]; }a[100]; int dx,dy; bool ju; void move(int x,int y) {rep(i,1,t1) {int dl=0,dr=0,il=0,ir=0;if(a[i].idx=="DR") {rep(j,1,a[i].n) {if(a[i].arr[j]==x) {ju=true;return ;}if(a[i].arr[j]<x) dr++;}}else if(a[i].idx=="DC") {rep(j,1,a[i].n) {if(a[i].arr[j]==y) {ju=true;return ;}if(a[i].arr[j]<y) dl++;}}else if(a[i].idx=="IR") {rep(j,1,a[i].n) {if(a[i].arr[j]<=x) ir++;}}else if(a[i].idx=="IC") {rep(j,1,a[i].n)if(a[i].arr[j]<=y) il++;}else if(a[i].idx=="EX") {if(a[i].arr[1]==x&&a[i].arr[2]==y) {x=a[i].arr[3];y=a[i].arr[4];}else if(a[i].arr[3]==x&&a[i].arr[4]==y) {x=a[i].arr[1];y=a[i].arr[2];}}x=x-dr;y=y-dl;x=x+ir;y=y+il;/*cout<<x<<" "<<y<<endl;*/}dx=x;dy=y; } int main() {#ifndef ONLINE_JUDGEfreopen("in.txt", "r", stdin);#endif//freopen("out.txt", "w", stdout);ios::sync_with_stdio(0),cin.tie(0);int l,r;int cnt=0;while(cin>>l>>r&&l) {cnt++;if(cnt!=1)cout<<endl;cin>>t1;rep(i,1,t1) {cin>>a[i].idx;if(a[i].idx=="EX") cin>>a[i].arr[1]>>a[i].arr[2]>>a[i].arr[3]>>a[i].arr[4];else {cin>>a[i].n;rep(j,1,a[i].n) cin>>a[i].arr[j];}}int t2;cin>>t2;cout<<"Spreadsheet #"<<cnt<<endl;rep(i,1,t2) {int x,y;dx=0;dy=0;ju=false;cin>>x>>y;move(x,y);if(ju) cout<<"Cell data in ("<<x<<","<<y<<") GONE"<<endl;else cout<<"Cell data in ("<<x<<","<<y<<") moved to ("<<dx<<","<<dy<<")"<<endl;}}return 0; }?
總結
以上是生活随笔為你收集整理的UVA - 512 Spreadsheet Tracking的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Angular 9 新功能摘要
- 下一篇: Windows子系统安装图形界面