https://www.acmicpc.net/problem/22352코드#include #include using namespace std;#define MAX 31#define FASTIO ios::sync_with_stdio(false); cin.tie(NULL);typedef pair pi;int n, m;int before[MAX][MAX], after[MAX][MAX];int dx[4] = { 1, -1, 0, 0 }, dy[4] = { 0, 0, 1, -1 };void bfs(int x, int y) { queue q; q.push({ x, y }); int now = before[x][y]; int changed = after[x][y]; while (!q.empty()) { int nx =..