Lang:G++
Edit12345678910111213141516171819202122232425262728293031#include<bits/stdc++.h>using namespace std;int get_father(int x, vector<int> &fa) {return fa[x] == x ? x : (fa[x] = get_father(fa[x], fa));}void un(int x, int y, vector<int> &fa) {//printf("x = %d y = %d\n", x, y);int fx = get_father(x, fa), fy = get_father(y, fa);if(fx != fy) {fa[fx] = fy;}}int main() {//freopen("in.txt", "r", stdin);int n, m;while(~scanf("%d%d", &n, &m)) {vector<vector<int> >w(n, vector<int>(m));for(int i = 0; i < n; i++) {char ch;scanf("%c", &ch);for(int j = 0; j < m; j++) {scanf("%c", &ch);if(ch == '\\') {w[i][j] = 1;}else if(ch == '/') {w[i][j] = 2;}else {w[i][j] = 0;}