結果
問題 |
No.179 塗り分け
|
ユーザー |
![]() |
提出日時 | 2015-04-06 00:11:57 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,417 bytes |
コンパイル時間 | 775 ms |
コンパイル使用メモリ | 81,516 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-10-02 13:23:48 |
合計ジャッジ時間 | 2,249 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 35 WA * 5 |
ソースコード
#include <iostream> #include <vector> #include <cstdio> #include <sstream> #include <map> #include <string> #include <algorithm> #include <queue> #include <cmath> #include <set> using namespace std; int main(){ int h, w; cin >> h >> w; vector<string> s(h); for(int i=0; i<h; i++){ cin >> s[i]; } bool ok = false; for(int dy=0; dy<h; dy++){ for(int dx=0; dx<w; dx++){ if(dx == dy && dx == 0) continue; bool valid = true; vector<vector<int>> c(h, vector<int>(w,-1)); int cnt = 0; for(int i=0; i<h && valid; i++){ for(int j=0; j<w && valid; j++){ int red = 0; int blue = 0; if(s[i][j] == '.') continue; if(c[i][j] != -1) continue; int x = j, y = i; int color = 0; while(!( y < 0 || y >= h || x < 0 || x >= w )){ if(s[y][x] == '.'){ break; } (color?red:blue) += 1; c[y][x] = color; color ^= 1; y += dy; x += dx; } x = j-dx, y = i-dy; color = 1; while(!( y < 0 || y >= h || x < 0 || x >= w )){ if(s[y][x] == '.'){ break; } (color?red:blue) += 1; c[y][x] = color; color ^= 1; y -= dy; x -= dx; } if(!(red>0 && blue>0 && red==blue)){ valid = false; break; }else{ cnt++; } } } if(valid && cnt > 0){ cout << "YES" << endl; return 0; } } } cout << "NO" << endl; return 0; }