結果
| 問題 | No.2412 YOU Grow Bigger! | 
| コンテスト | |
| ユーザー |  shobonvip | 
| 提出日時 | 2023-08-11 22:12:39 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 281 ms / 6,000 ms | 
| コード長 | 2,458 bytes | 
| コンパイル時間 | 4,200 ms | 
| コンパイル使用メモリ | 261,144 KB | 
| 最終ジャッジ日時 | 2025-02-16 01:30:56 | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 29 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/
/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/
typedef long long ll;
#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)
template <typename T> bool chmin(T &a, const T &b) {
	if (a <= b) return false;
	a = b;
	return true;
}
template <typename T> bool chmax(T &a, const T &b) {
	if (a >= b) return false;
	a = b;
	return true;
}
template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}
template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}
template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}
bool solve(int h, int w, vector<vector<char>> &c){
	vector<vector<bool>> tansaku(h-2, vector<bool>(w-2));
	tansaku[0][0] = true;
	rep(i,0,3){
		rep(j,0,3){
			if (c[i][j] == '#') return false;
		}
	}
	vector<vector<bool>> good(h-2, vector<bool>(w-2));
	rep(x,0,h-2){
		rep(y,0,w-2){
			bool mode = true;
			rep(xx,x,x+3){
				rep(yy,y,y+3){
					if (c[xx][yy] == '#'){
						mode = false;
					}
				}
			}
			good[x][y] = mode;
		}
	}
	vector<pair<int,int>> mada = {pair(0, 0)};
	while(!mada.empty()){
		auto [i, j] = mada.back();
		mada.pop_back();
		rep(x,i-1,i+2){
			rep(y,j-1,j+2){
				if (!(0 <= x && x < h-2)) continue;
				if (!(0 <= y && y < w-2)) continue;
				if (tansaku[x][y]) continue;
				if (!good[x][y]) continue;
				tansaku[x][y] = true;
				mada.push_back(pair(x, y));
			}
		}
	}
	return tansaku[h-3][w-3];
}
int main(){
	int h, w; cin >> h >> w;
	vector<vector<char>> c(h, vector<char>(w));
	rep(i,0,h){
		rep(j,0,w){
			cin >> c[i][j];
		}
	}
	if (!solve(h, w, c)){
		cout << 0 << '\n';
		return 0;
	}
	rep(i,0,h-1){
		rep(j,0,w-1){
			vector<vector<char>> cc = c;
			cc[i][j] = '#';
			bool mode = true;
			rep(i,0,3){
				rep(j,0,3){
					if (cc[i][j] == '#') mode = false;
				}
			}
			rep(i,h-3,h){
				rep(j,w-3,w){
					if (cc[i][j] == '#') mode = false;
				}
			}
			if (!mode) continue;
			if (!solve(h, w, cc)){
				cout << 1 << '\n';
				return 0;
			}
		}
	}
	cout << 2 << '\n';
}
            
            
            
        