真的是,又写了50多分钟,主要是中间出了两个错误,耽误了很多时间,第一个错误是交换操作,没有写else,这样子的话需要交换的时候交换不了,发生逻辑错误,第二个是本题用的是vector,那么每组数据之后是要清空的,至少目前我会的vector的操作很少,只能这样写,这样写的好处就是省去了记录插入删除的数目,vector的size就是,但是坏处就是我出错的地方,
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define sz(x) ((int) (x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pa;
const int N = 1e4 + 5;
string s[N];
int main() {
int r, c;
int num = 1;
while (cin >> r >> c) {
if (!r && !c) break;
if (num > 1) cout << endl;
cout << "Spreadsheet #" << num++ << endl;
int n;
cin >> n;
vi v[N];
for (int i = 0; i < n; i++) {
cin >> s[i];
if (s[i] != "EX") {
int x;
cin >> x;
for (int j = 0; j < x; j++) { int t; cin >> t; v[i].pb(t); }
sort(all(v[i]));
} else {
for (int j = 0; j < 4; j++) { int t; cin >> t; v[i].bp(t); }
}
}
int q;
cin >> q;
while (q--) {
int x, y;
cin >> x >> y;
int xx = x, yy = y;
int ok = 0;
for (int i = 0; i < n; i++) {
if (s[i] == "IR") {
int j;
for (j = 0; j < sz(v[i]); j++) {
if (v[i][j] > x) break;
}
x += j;
} else if (s[i] == "IC") {
int j;
for (j = 0; j < sz(v[i]); j++) {
if (v[i][j] > y) break;
}
y += j;
} else if (s[i] == "DR") {
int cnt = 0;
for (int j = 0; j < sz(v[i]); j++) {
if (v[i][j] < x) cnt++;
if (v[i][j] == x) cnt = -1;
}
if (cnt == -1) { ok = 1; break; }
else x -= cnt;
} else if (s[i] == "DC") {
int cnt = 0;
for (int j = 0; j < sz(v[i]); j++) {
if (v[i][j] < y) cnt++;
if (v[i][j] == y) cnt = -1;
}
if (cnt == -1) { ok = 1; break; }
else y -= cnt;
} else {
int x1 = v[i][0], y1 = v[i][1];
int x2 = v[i][2], y2 = v[i][3];
if (x1 == x && y1 == y) { x = x2; y = y2; }
else if (x2 == x && y2 == y) { x = x1; y = y1; }
}
}
if (ok) printf("Cell data in (%d,%d) GONE\n", xx, yy);
else printf("Cell data in (%d,%d) moved to (%d,%d)\n", xx, yy, x, y);
}
}
return 0;
}