結果

問題 No.2641 draw X
ユーザー maeshunmaeshun
提出日時 2024-02-20 10:38:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,249 bytes
コンパイル時間 5,921 ms
コンパイル使用メモリ 290,028 KB
実行使用メモリ 124,732 KB
最終ジャッジ日時 2024-02-20 10:38:36
合計ジャッジ時間 30,389 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,480 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 WA -
testcase_11 AC 2 ms
6,676 KB
testcase_12 WA -
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 1,445 ms
124,732 KB
testcase_16 TLE -
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 154 ms
11,380 KB
testcase_21 AC 328 ms
28,156 KB
testcase_22 AC 162 ms
11,116 KB
testcase_23 AC 246 ms
18,924 KB
testcase_24 AC 76 ms
11,068 KB
testcase_25 AC 71 ms
10,600 KB
testcase_26 AC 411 ms
28,000 KB
testcase_27 AC 89 ms
9,816 KB
testcase_28 AC 750 ms
64,740 KB
testcase_29 AC 1,291 ms
118,772 KB
testcase_30 AC 1,241 ms
107,992 KB
testcase_31 AC 1,069 ms
62,340 KB
testcase_32 AC 1,789 ms
119,964 KB
testcase_33 TLE -
testcase_34 AC 1,549 ms
64,408 KB
testcase_35 AC 1,351 ms
61,100 KB
testcase_36 AC 1,982 ms
115,844 KB
testcase_37 TLE -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, n) for(int i=0;i<(n);++i)
#define rep1(i, n) for(int i=1;i<=(n);i++)
#define ll long long
using mint = modint998244353;
using P = pair<ll,ll>;
using lb = long double;
using T = tuple<ll, ll, ll>;
#ifdef LOCAL
#  include <debug_print.hpp>
#  define dbg(...) debug_print::multi_print(#__VA_ARGS__, __VA_ARGS__)
#else
#  define dbg(...) (static_cast<void>(0))
#endif

int main()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	rep(i,h) cin >> s[i];
	map<int, vector<int>> a, b;
	rep(i,h)rep(j,w){
		a[i+j].push_back(-1);
		a[i+j].push_back(w);
		b[i-j].push_back(-1);
		b[i-j].push_back(w);
		if(s[i][j]=='.') {
			a[i+j].push_back(j);
			b[i-j].push_back(j);
		}
	}
	for(auto &p : a){
		sort(p.second.begin(),p.second.end());
		p.second.erase(unique(p.second.begin(),p.second.end()), p.second.end());
	}

	for(auto &p : b){
		sort(p.second.begin(),p.second.end());
		p.second.erase(unique(p.second.begin(),p.second.end()), p.second.end());
	}
	dbg(a,b);
	vector<vector<vector<int>>> dp(4, vector<vector<int>>(h, vector<int>(w)));
	rep(i,h)rep(j,w){
		if(s[i][j]=='#'){
			int p = lower_bound(a[i+j].begin(),a[i+j].end(), j) - a[i+j].begin();
			int q = p-1;
			int r = lower_bound(b[i-j].begin(),b[i-j].end(), j) - b[i-j].begin();
			int s = r-1;
			int d = min(a[i+j][p]-j, j-a[i+j][q]);
			d = min(d, b[i-j][r]-j);
			d = min(d, j-b[i-j][s]);
			if(d==1) continue;
			rep(k,4) dp[k][i][j] = max(dp[k][i][j], d);
			dbg(i,j,d);
		}
	}
	using R = tuple<int, int, int, int>;
	priority_queue<R> pq;
	rep(i,h)rep(j,w){
		rep(k,4) pq.emplace(dp[k][i][j], i,j,k);
	}
	vector<int> di = {-1,-1,1,1};
	vector<int> dj = {-1,1,-1,1};
	while(!pq.empty()){
		auto [d, x, y, k] = pq.top();pq.pop();
		if(dp[k][x][y]!=d) continue;
		int nx = x + di[k];
		int ny = y + dj[k];
		if(nx<0 || ny<0 || nx>=h || ny>=w) continue;
		if(s[nx][ny]=='.') continue;
		if(dp[k][nx][ny]<d-1) {
			dp[k][nx][ny] = d-1;
			pq.emplace(d-1, nx, ny, k);
		}
	}
	dbg(dp);
	rep(i,h)rep(j,w){
		if(s[i][j]=='#'){
			int d = 0;
			rep(k,4){
				d = max(d, dp[k][i][j]);
			}
			if(d==0){
				cout << "No" << endl;
				return 0;
			}
		}
	}
	cout << "Yes" << endl;
	return 0;
}
0