結果
| 問題 |
No.2641 draw X
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-19 22:04:28 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 50 ms / 2,000 ms |
| コード長 | 2,374 bytes |
| コンパイル時間 | 3,452 ms |
| コンパイル使用メモリ | 256,240 KB |
| 実行使用メモリ | 27,904 KB |
| 最終ジャッジ日時 | 2024-09-29 02:01:14 |
| 合計ジャッジ時間 | 5,293 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 41 |
ソースコード
// #pragma GCC optimize("O3,unroll-loops")
#include <bits/stdc++.h>
// #include <x86intrin.h>
using namespace std;
#if __cplusplus >= 202002L
using namespace numbers;
#endif
template<class T> T &ctmin(T &x){ return x; }
template<class T, class Head, class ...Tail> T &ctmin(T &x, const Head &h, const Tail &... t){ return ctmin(x = min<T>(x, h), t...); }
template<class T> T &ctmax(T &x){ return x; }
template<class T, class Head, class ...Tail> T &ctmax(T &x, const Head &h, const Tail &... t){ return ctmax(x = max<T>(x, h), t...); }
int main(){
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(ios::badbit | ios::failbit);
int nr, nc;
cin >> nr >> nc;
vector<string> a(nr);
copy_n(istream_iterator<string>(cin), nr, a.begin());
vector ul(nr, vector(nc, 1));
auto ur = ul;
auto dl = ul;
auto dr = ul;
for(auto x = 0; x < nr; ++ x){
for(auto y = 0; y < nc; ++ y){
if(a[x][y] == '.'){
ul[x][y] = ur[x][y] = 0;
continue;
}
if(x >= 1){
if(y >= 1){
ul[x][y] = ul[x - 1][y - 1] + 1;
}
if(y + 1 < nc){
ur[x][y] = ur[x - 1][y + 1] + 1;
}
}
}
}
for(auto x = nr - 1; x >= 0; -- x){
for(auto y = 0; y < nc; ++ y){
if(a[x][y] == '.'){
dl[x][y] = dr[x][y] = 0;
continue;
}
if(x + 1 < nr){
if(y >= 1){
dl[x][y] = dl[x + 1][y - 1] + 1;
}
if(y + 1 < nc){
dr[x][y] = dr[x + 1][y + 1] + 1;
}
}
}
}
vector<vector<int>> res_sum(nr, vector<int>(nc));
vector<vector<int>> res_dif(nr, vector<int>(nc));
for(auto x = 1; x < nr - 1; ++ x){
for(auto y = 1; y < nc - 1; ++ y){
int radius = min({ul[x][y], ur[x][y], dl[x][y], dr[x][y]});
if(radius <= 1){
continue;
}
++ res_sum[x - radius + 1][y - radius + 1];
if(x + radius < nr && y + radius < nc){
-- res_sum[x + radius][y + radius];
}
++ res_dif[x - radius + 1][y + radius - 1];
if(x + radius < nr && y - radius >= 0){
-- res_dif[x + radius][y - radius];
}
}
}
for(auto x = 0; x < nr - 1; ++ x){
for(auto y = 0; y < nc; ++ y){
if(y + 1 < nc){
res_sum[x + 1][y + 1] += res_sum[x][y];
}
if(y - 1 >= 0){
res_dif[x + 1][y - 1] += res_dif[x][y];
}
}
}
for(auto x = 0; x < nr; ++ x){
for(auto y = 0; y < nc; ++ y){
if(!!(res_sum[x][y] + res_dif[x][y]) != (a[x][y] == '#')){
cout << "No\n";
return 0;
}
}
}
cout << "Yes\n";
return 0;
}
/*
*/