結果
問題 | No.2641 draw X |
ユーザー |
|
提出日時 | 2024-03-10 20:37:51 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,633 bytes |
コンパイル時間 | 2,232 ms |
コンパイル使用メモリ | 215,624 KB |
実行使用メモリ | 67,236 KB |
最終ジャッジ日時 | 2024-09-29 21:46:34 |
合計ジャッジ時間 | 6,604 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 15 |
ソースコード
#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; } 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<int> Sp, Sm; auto rec = [&](auto rec, int y, int x, int ds) -> int { if(y < 0 || x < 0 || y >= h || x >= w) return 1; 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] = 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; bool flg = true; for(int s = 0; s < 4; s++){ if(rec(rec, y, x, s) == 0){ flg = false; break; } } if(flg){ Sp.push_back(y + x); Sm.push_back(y - x); } } } sort(Sp.begin(), Sp.end()); Sp.erase(unique(Sp.begin(), Sp.end()), Sp.end()); sort(Sm.begin(), Sm.end()); Sm.erase(unique(Sm.begin(), Sm.end()), Sm.end()); for(int y = 0; y < h; y++){ for(int x = 0; x < w; x++){ if(A[y][x] == '.') continue; if(binary_search(Sp.begin(), Sp.end(), y + x) || binary_search(Sm.begin(), Sm.end(), y - x))continue; cout << "No\n"; return 0; } } cout << "Yes\n"; }