結果
問題 | No.2641 draw X |
ユーザー |
![]() |
提出日時 | 2024-02-19 22:04:39 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 3,450 bytes |
コンパイル時間 | 2,785 ms |
コンパイル使用メモリ | 212,796 KB |
実行使用メモリ | 60,416 KB |
最終ジャッジ日時 | 2024-09-29 02:01:31 |
合計ジャッジ時間 | 5,133 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 41 |
ソースコード
#pragma GCC optimize("O2")#include <algorithm>#include <array>#include <bit>#include <bitset>#include <cassert>#include <cctype>#include <cfenv>#include <cfloat>#include <chrono>#include <cinttypes>#include <climits>#include <cmath>#include <compare>#include <complex>#include <concepts>#include <cstdarg>#include <cstddef>#include <cstdint>#include <cstdio>#include <cstdlib>#include <cstring>#include <deque>#include <fstream>#include <functional>#include <initializer_list>#include <iomanip>#include <ios>#include <iostream>#include <istream>#include <iterator>#include <limits>#include <list>#include <map>#include <memory>#include <new>#include <numbers>#include <numeric>#include <ostream>#include <queue>#include <random>#include <ranges>#include <set>#include <span>#include <sstream>#include <stack>#include <streambuf>#include <string>#include <tuple>#include <type_traits>#include <variant>#define int ll#define INT128_MAX (__int128)(((unsigned __int128) 1 << ((sizeof(__int128) * __CHAR_BIT__) - 1)) - 1)#define INT128_MIN (-INT128_MAX - 1)#define clock chrono::steady_clock::now().time_since_epoch().count()#ifdef DEBUG#define dbg(x) cout << (#x) << " = " << x << '\n'#else#define dbg(x)#endifnamespace R = std::ranges;namespace V = std::views;using namespace std;using ll = long long;using ull = unsigned long long;using ldb = long double;using pii = pair<int, int>;using pll = pair<ll, ll>;//#define double ldbtemplate<class T>ostream& operator<<(ostream& os, const pair<T, T> pr) {return os << pr.first << ' ' << pr.second;}template<class T, size_t N>ostream& operator<<(ostream& os, const array<T, N> &arr) {for(const T &X : arr)os << X << ' ';return os;}template<class T>ostream& operator<<(ostream& os, const vector<T> &vec) {for(const T &X : vec)os << X << ' ';return os;}template<class T>ostream& operator<<(ostream& os, const set<T> &s) {for(const T &x : s)os << x << ' ';return os;}signed main() {ios::sync_with_stdio(false), cin.tie(NULL);int h, w; cin >> h >> w;vector g(h + 2, string(w + 2, '.'));for(int i = 1; i <= h; i++) {string s; cin >> s;g[i] = '.' + s + '.';}vector dp(4, vector(h + 2, vector<int>(w + 2)));for(int i = 1; i <= h; i++) {for(int j = 1; j <= w; j++) {if (g[i][j] == '.') continue;dp[0][i][j] = dp[0][i - 1][j - 1] + 1;dp[1][i][j] = dp[1][i - 1][j + 1] + 1;}}for(int i = h; i >= 1; i--) {for(int j = 1; j <= w; j++) {if (g[i][j] == '.') continue;dp[2][i][j] = dp[2][i + 1][j - 1] + 1;dp[3][i][j] = dp[3][i + 1][j + 1] + 1;}}vector pre(2, vector(h + 2, vector<int>(w + 2)));for(int i = 1; i <= h; i++) {for(int j = 1; j <= w; j++) {if (g[i][j] == '.') continue;int d = min({dp[0][i][j], dp[1][i][j], dp[2][i][j], dp[3][i][j]});if (d <= 1) continue;pre[0][i - d + 1][j - d + 1]++, pre[0][i + d][j + d]--;pre[1][i - d + 1][j + d - 1]++, pre[1][i + d][j - d]--;}}for(int i = 1; i <= h; i++)for(int j = 1; j <= w; j++)pre[0][i][j] += pre[0][i - 1][j - 1], pre[1][i][j] += pre[1][i - 1][j + 1];bool ok = true;for(int i = 1; i <= h; i++)for(int j = 1; j <= w; j++)if (g[i][j] == '#')ok = ok and (pre[0][i][j] + pre[1][i][j] > 0);cout << (ok ? "Yes\n" : "No\n");return 0;}