結果
問題 |
No.179 塗り分け
|
ユーザー |
![]() |
提出日時 | 2015-07-08 22:12:01 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 852 bytes |
コンパイル時間 | 1,408 ms |
コンパイル使用メモリ | 164,260 KB |
実行使用メモリ | 10,020 KB |
最終ジャッジ日時 | 2024-10-02 14:35:34 |
合計ジャッジ時間 | 6,206 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 6 TLE * 1 -- * 33 |
ソースコード
#include <bits/stdc++.h> using namespace std; int h,w; bool check(int mx,int my,vector<string> s){ for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(s[i][j]=='#'){ if(!(0<=i+my&&i+my<h&&0<=j+mx&&j+mx<w)) continue; s[i][j]='R'; if(s[i+my][j+mx]=='#') s[i+my][j+mx]='B'; else return false; } } } for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(s[i][j]=='#') return false; } } return true; } void end(){ cout<<"YES"<<endl; exit(0); } int main(){ cin>>h>>w; vector<string> s(h); for(int i=0;i<h;i++) cin>>s[i]; for(int i=0;i<h;i++){ for(int j=0;j<w;j++){ if(s[i][j]=='#'){ for(int toj=j+1;toj<w;toj++){ if(check(toj-j,0,s)) end(); } for(int toi=i+1;toi<h;toi++){ for(int toj=0;toj<w;toj++){ if(check(toj-j,toi-i,s)) end(); } } } } } cout<<"NO"<<endl; return 0; }