#include <bits/stdc++.h>
using namespace std;
typedef long double LD;
typedef long long LL;
const int MAX = 0x3f3f3f3f;
const LL LMA = 0x3fffffffffffffff;
const double PI = acos(-1.0);
const int MOD = 1e9 + 7;
const int N = 1000010;
int a[1010][1010];
int b[1000010];
int c[1000010];
int main()
{
ios::sync_with_stdio(false);
cin.tie(0), cout.tie(0);
int n, m;
cin >> n >> m;
memset(a, 0, sizeof(a));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
int x;
cin >> x;
a[i][j] = x;
}
}
int k;
cin >> k;
for (int i = 0; i < k; i++) {
int x, y, x2, y2;
cin >> x >> y >> x2 >> y2;
int c = a[x][y];
a[x][y] = a[x2][y2];
a[x2][y2] = c;
}
int cnt = 0;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
int fg = 1;
if (i >= 2 && a[i - 1][j] >= a[i][j])
fg = 0;
if (i <= n - 1 && a[i + 1][j] >= a[i][j])
fg = 0;
if (j >= 2 && a[i][j - 1] >= a[i][j])
fg = 0;
if (i <= m - 1 && a[i][j + 1] >= a[i][j])
fg = 0;
if (fg == 1) {
b[cnt] = i;
c[cnt] = j;
cnt++;
}
}
}
cout << cnt << "\n";
for (int i = 0; i < cnt; i++) {
cout << b[i] << " " << c[i] << "\n";
}
}
已经看过题解和讨论,无法发现问题,感谢帮助
评测记录