結果
| 問題 | No.2641 draw X |
| コンテスト | |
| ユーザー |
Rubikun
|
| 提出日時 | 2024-02-19 21:38:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 88 ms / 2,000 ms |
| コード長 | 3,334 bytes |
| コンパイル時間 | 2,155 ms |
| コンパイル使用メモリ | 209,472 KB |
| 最終ジャッジ日時 | 2025-02-19 16:45:49 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=300005,INF=1<<30;
vector<int> dh={-1,-1,1,1},dw={-1,1,-1,1};
int main(){
std::ifstream in("text.txt");
std::cin.rdbuf(in.rdbuf());
cin.tie(0);
ios::sync_with_stdio(false);
int H,W;cin>>H>>W;
vector<string> S(H);
for(int i=0;i<H;i++){
cin>>S[i];
}
vector<vector<vector<int>>> dp(4,vector<vector<int>>(H,vector<int>(W))),T;
T=dp;
for(int t=0;t<4;t++){
if(t<2){
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
if(S[i][j]=='.') continue;
else{
int toh=i+dh[t],tow=j+dw[t];
if(0<=toh&&toh<H&&0<=tow&&tow<W){
dp[t][i][j]=dp[t][toh][tow]+1;
}else{
dp[t][i][j]=1;
}
}
}
}
}else{
for(int i=H-1;i>=0;i--){
for(int j=0;j<W;j++){
if(S[i][j]=='.') continue;
else{
int toh=i+dh[t],tow=j+dw[t];
if(0<=toh&&toh<H&&0<=tow&&tow<W){
dp[t][i][j]=dp[t][toh][tow]+1;
}else{
dp[t][i][j]=1;
}
}
}
}
}
}
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
int can=INF;
for(int k=0;k<4;k++) chmin(can,dp[k][i][j]);
if(can>=2){
for(int k=0;k<4;k++){
T[k][i][j]=can;
//cout<<T[k][i][j]<<" "<<i<<" "<<j<<endl;
}
}
}
}
for(int t=0;t<4;t++){
if(t>=2){
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
if(T[t][i][j]<=1) continue;
else{
int toh=i+dh[t],tow=j+dw[t];
chmax(T[t][toh][tow],T[t][i][j]-1);
}
}
}
}else{
for(int i=H-1;i>=0;i--){
for(int j=0;j<W;j++){
if(T[t][i][j]<=1) continue;
else{
int toh=i+dh[t],tow=j+dw[t];
chmax(T[t][toh][tow],T[t][i][j]-1);
}
}
}
}
}
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
int f=0;
for(int k=0;k<4;k++) if(T[k][i][j]) f=1;
if(S[i][j]=='#'){
if(f==0){
cout<<"No\n";
return 0;
}
}else{
if(f){
cout<<"No\n";
return 0;
}
}
}
}
cout<<"Yes\n";
}
Rubikun