結果
問題 | No.179 塗り分け |
ユーザー |
|
提出日時 | 2022-06-22 10:27:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,038 bytes |
コンパイル時間 | 1,867 ms |
コンパイル使用メモリ | 178,100 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-15 13:56:14 |
合計ジャッジ時間 | 4,935 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 38 WA * 2 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int H, W; cin >> H >> W; vector<string> A(H); for(auto &&s:A)cin >> s; for(int my = 0; my <= H; my++){ for(int mx = 0; mx <= W; mx++){ if(my == 0 && mx == 0)continue; bool flag = true; vector<vector<bool>> used(H, vector<bool>(W)); for(int y = 0; y < H; y++){ for(int x = 0; x < W; x++){ if(used[y][x])continue; if(A[y][x] != '#')continue; if(y + my >= H || x + mx >= W){ flag = false; continue; } used[y][x] = true; if(A[y + my][x + mx] == '#'){ used[y + my][x + mx] = true; }else{ flag = false; } } } if(flag){ cout << "YES" << '\n'; return 0; } } } for(auto &&s:A)reverse(s.begin(), s.end()); for(int my = 0; my <= H; my++){ for(int mx = 0; mx <= W; mx++){ if(my == 0 && mx == 0)continue; bool flag = true; vector<vector<bool>> used(H, vector<bool>(W)); for(int y = 0; y < H; y++){ for(int x = 0; x < W; x++){ if(used[y][x])continue; if(A[y][x] != '#')continue; if(y + my >= H || x + mx >= W){ flag = false; continue; } used[y][x] = true; if(A[y + my][x + mx] == '#'){ used[y + my][x + mx] = true; }else{ flag = false; } } } if(flag){ cout << "YES" << '\n'; return 0; } } } cout << "NO" << '\n'; }