結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
hikariri
|
| 提出日時 | 2023-03-18 16:01:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,534 bytes |
| コンパイル時間 | 4,011 ms |
| コンパイル使用メモリ | 234,044 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-09-18 13:23:18 |
| 合計ジャッジ時間 | 5,469 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 31 WA * 9 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#if __has_include(<atcoder/all>)
#include <atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
#endif
typedef long long ll;
typedef pair<int,int> pii; typedef pair<ll,ll> pll;
const int INF = 1e9; const long long LINF = 1e18;
const int MOD = 998244353; const int MOD1 = 1e9+7;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(x) x.begin(), x.end()
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
void yorn(bool ans){cout << (ans?"Yes":"No") << endl; return;}
int main(){
int h,w; cin >> h >> w;
vector<string> g(h); rep(i,h) cin >> g.at(i);
bool ans = false;
int sy=INF,sx=INF;
bool d = false;
rep(i,h){
rep(j,w){
if(g.at(i).at(j)=='#'){
sy = i; sx = j;
g.at(i).at(j) = 'R';
}
if(!d) break;
}
if(!d) break;
}
//cout << "(sy,sx)=("<<sy<<','<<sx<<')'<<endl;
for(int i=sy;i<h;i++){
for(int j=0;j<w;j++){
if(i==sy && j<=sx) continue;
if(g.at(i).at(j)=='#'){
//cout << i << ' ' << j << endl;
auto gg = g;
gg.at(i).at(j) = 'B';
int dy = i-sy, dx = j-sx;
bool ok = true;
for(int ii=sy;ii<h;ii++){
for(int jj=0;jj<w;jj++){
if(ii==sy && jj<=sy) continue;
if(gg.at(ii).at(jj)=='#'){
gg.at(ii).at(jj) = 'R';
if(ii==h-1&&jj==w-1) ok = false;
if(0<=ii+dy&&ii+dy<h && 0<=jj+dx&&jj+dx<w && gg.at(ii+dy).at(jj+dx)=='#'){
gg.at(ii+dy).at(jj+dx) = 'B';
}
else{//cout << "(i,j)=("<<i<<','<<j<<')'<<' '<<ii<<' '<<jj<<endl;
//rep(p,h){rep(q,w){cout<<gg.at(p).at(q);}cout << endl;}
ok = false;}
}
if(!ok) break;
}
if(!ok) break;
}
if(ok){
//cout <<99999<< endl;
ans = true;
}
//else cout << i << ' ' << j << endl;
}
}
}
cout << (ans?"YES":"NO") << endl;
}
hikariri