結果
問題 | No.2641 draw X |
ユーザー |
|
提出日時 | 2024-03-10 20:49:04 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,054 bytes |
コンパイル時間 | 2,071 ms |
コンパイル使用メモリ | 212,120 KB |
実行使用メモリ | 67,072 KB |
最終ジャッジ日時 | 2024-09-29 21:47:04 |
合計ジャッジ時間 | 6,908 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 39 WA * 2 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; template<class T> istream& operator >> (istream& is, vector<T>& vec) { for(T& x : vec) is >> x; return is; } template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { if(vec.empty()) return os; os << vec[0]; for(auto it = vec.begin(); ++it != vec.end(); ) os << ' ' << *it; return os; } int main(){ ios::sync_with_stdio(false); cin.tie(0); int h, w; cin >> h >> w; vector<string> A(h); cin >> A; vector dp(h, vector(w, vector<int>(4, -1))); vector dp2(h, vector<int>(w)), dp3(h, vector<int>(w)); auto rec = [&](auto rec, int y, int x, int ds) -> int { if(y < 0 || x < 0 || y >= h || x >= w) return 0; if(dp[y][x][ds] != -1) return dp[y][x][ds]; if(A[y][x] == '.') return dp[y][x][ds] = 0; return dp[y][x][ds] = 1 + rec(rec, y + (ds & 1 ? 1 : -1), x + (ds & 2 ? 1 : -1), ds); }; for(int y = 0; y < h; y++){ for(int x = 0; x < w; x++){ if(A[y][x] == '.') continue; int ans = 1 << 30; for(int s = 0; s < 4; s++){ ans = min(ans, rec(rec, y, x, s)); } if(ans >= 2) dp2[y][x] = dp3[y][x] = ans; } } for(int y = 0; y + 1 < h; y++){ for(int x = 0; x < w; x++){ if(x + 1 < w) dp2[y + 1][x + 1] = max(dp2[y + 1][x + 1], dp2[y][x] - 1); if(x >= 1) dp2[y + 1][x - 1] = max(dp2[y + 1][x - 1], dp2[y][x] - 1); } } for(int y = h - 1; y >= 1; y--){ for(int x = 0; x < w; x++){ if(x + 1 < w) dp3[y - 1][x + 1] = max(dp3[y - 1][x + 1], dp3[y][x] - 1); if(x >= 1) dp3[y - 1][x - 1] = max(dp3[y - 1][x - 1], dp3[y][x] - 1); } } for(int y = 0; y < h; y++){ for(int x = 0; x < w; x++){ if(A[y][x] == '.') continue; if(dp2[y][x] + dp3[y][x] == 0){ cout << "No\n"; return 0; } } } cout << "Yes\n"; }