#include //#include //#pragma GCC optimize("Ofast") using namespace std; #define reps(i,s,n) for(int i = s; i < n; i++) #define rep(i,n) reps(i,0,n) #define Rreps(i,n,e) for(int i = n - 1; i >= e; --i) #define Rrep(i,n) Rreps(i,n,0) #define ALL(a) a.begin(), a.end() using ll = long long; using vec = vector; using mat = vector; ll N,M,H,W,Q,K,A,B; string S; using P = pair; const ll INF = (1LL<<60); template bool chmin(T &a, const T b){ if(a > b) {a = b; return true;} else return false; } template bool chmax(T &a, const T b){ if(a < b) {a = b; return true;} else return false; } template void my_printv(std::vector v,bool endline = true){ if(!v.empty()){ for(std::size_t i{}; i; void add_edge(int from, int to, ll cap, vector &G, bool directed = true){ G[from].emplace_back(to, cap, (int)G[to].size()); G[to].emplace_back(from, directed ? 0 : cap, (int)G[from].size() - 1); } void bfs(int s, vector &G, vector &level){ queue que; level[s] = 0; que.push(s); while(!que.empty()){ int v = que.front(); que.pop(); for(edge &e : G[v]){ if(e.cap > 0 && chmin(level[e.to], level[v] + 1)){ que.push(e.to); } } } } ll dfs(int v, int t, ll f, vector &G, vector &level, vector &iter){ if(v == t) return f; for(int &i = iter[v]; i < G[v].size(); ++i){ edge &e = G[v][i]; if(e.cap > 0 && level[v] < level[e.to]){ ll d = dfs(e.to, t, min(f, e.cap), G, level, iter); if(d > 0){ e.cap -= d; G[e.to][e.rev].cap += d; return d; } } } return 0; } ll dinic(int s, int t, vector &G){ ll res = 0; int sz = G.size(); for( ; ; ){ vector level(sz, INT_MAX), iter(sz, 0); bfs(s, G, level); if(level[t] == INT_MAX) return res; ll f; while((f = dfs(s, t, INF, G, level, iter)) > 0) res += f; } } void no(){ cout<<"No"< input; int last = -1; string T; bool bipartite_matching(vector &res){ const int st = H * W, gl = H * W + 1; const vector di = {-1, 0, 1, 0}, dj = {0, -1, 0, 1}; vector G(H * W + 2); int flow_num{}; rep(i, H) { rep(j, W){ if(res[i][j] == '.') continue; ++flow_num; int id = i * W + j; if((i + j)&1){ add_edge(st, id, 1, G); rep(k, 4){ int ni = i + di[k], nj = j + dj[k]; if(ni >= 0 && ni < H && nj >= 0 && nj < W && res[ni][nj] == '#'){ add_edge(id, ni * W + nj, 1, G); } } }else{ add_edge(id, gl, 1, G); } } } if(flow_num&1) return false; flow_num >>= 1; int actually_flow_num = dinic(st, gl, G); if(flow_num != actually_flow_num) return false; bool dai = false; int char_num = 0; rep(i, H) { rep(j, W) { if (res[i][j] == '.') continue; int id = i * W + j; if((i + j)&1) { for (edge &e : G[id]) { if (e.cap == 0 && e.to != st) { res[i][j] = res[e.to / W][e.to % W] = char((dai ? 'A' : 'a') + char_num); if ((++char_num) == 25) { char_num = 0; dai = true; } break; } } } } } return true; } bool dfs(int res_id, int input_id, vector &res){ //cout<>H>>W; S = string(W, '.'); T = string(W, '#'); vector res(H, S); input.resize(H); rep(i, H) { cin>>input[i]; if(input[i] == S){ if(last != i - 1) no(); last = i; } if(input[i] == T) no(); } if(dfs(H - 1, H - 1, res)){ cout<<"Yes"<