結果
| 問題 |
No.2641 draw X
|
| コンテスト | |
| ユーザー |
noya2
|
| 提出日時 | 2024-02-13 21:01:11 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 2,379 bytes |
| コンパイル時間 | 3,185 ms |
| コンパイル使用メモリ | 258,464 KB |
| 実行使用メモリ | 813,696 KB |
| 最終ジャッジ日時 | 2024-09-28 18:37:24 |
| 合計ジャッジ時間 | 6,843 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 1 RE * 6 MLE * 1 -- * 15 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
template<typename T>
bool chmax(T &a, const T &b){
if (a >= b){
return false;
}
a = b;
return true;
}
template<typename T>
bool chmin(T &a, const T &b){
if (a <= b){
return false;
}
a = b;
return true;
}
vector<vector<int>> max_ur(vector<vector<char>> &a){
int h = a.size();
int w = a[0].size();
vector<vector<int>> ans(h,vector<int>(w,0));
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
if (a[i][j] == '#'){
ans[i][j] = 1;
if (i > 0 && j > 0){
chmax(ans[i][j],ans[i-1][j-1]+1);
}
}
}
return ans;
}
template<typename T>
void rotated(vector<vector<T>> &a){
int h = a.size();
int w = a[0].size();
vector<vector<T>> b(w,vector<T>(w));
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
b[j][h-1-i] = a[i][j];
}
swap(a,b);
}
int main(){
int h, w; cin >> h >> w;
vector<vector<char>> a(h,vector<char>(w));
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
cin >> a[i][j];
}
vector<vector<int>> dp(h,vector<int>(w,h+w));
for (int t = 0; t < 4; t++){
auto ep = max_ur(a);
for (int s = 0; s < 4-t; s++){
rotated(ep);
}
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
chmin(dp[i][j],ep[i][j]);
}
rotated(a);
}
vector<vector<int>> imosm(h,vector<int>(w,0)), imosp(h,vector<int>(w,0));
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
if (dp[i][j] <= 1) continue;
int r = dp[i][j]-1;
imosm[i-r][j-r]++;
if (i+r+1 < h && j+r+1 < w){
imosm[i+r+1][j+r+1]--;
}
imosp[i-r][j+r]++;
if (i+r+1 < h && j-r-1 >= 0){
imosp[i+r+1][j-r-1]--;
}
}
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
if (i+1 < h && j+1 < w){
imosm[i+1][j+1] += imosm[i][j];
}
if (i+1 < h && j-1 >= 0){
imosp[i+1][j-1] += imosp[i][j];
}
}
bool ans = true;
for (int i = 0; i < h; i++) for (int j = 0; j < w; j++){
if (a[i][j] == '#' && imosm[i][j]+imosp[i][j] == 0){
ans = false;
break;
}
}
cout << (ans ? "Yes" : "No") << endl;
}
noya2