結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2018-08-09 14:59:02 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 35 ms / 3,000 ms |
| コード長 | 937 bytes |
| コンパイル時間 | 1,665 ms |
| コンパイル使用メモリ | 170,488 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-23 14:50:29 |
| 合計ジャッジ時間 | 3,394 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
Int h,w;
cin>>h>>w;
vector<string> s(h);
for(Int i=0;i<h;i++) cin>>s[i];
{
Int cnt=0;
for(Int i=0;i<h;i++)
for(Int j=0;j<w;j++)
cnt+=s[i][j]=='#';
if(cnt==0){
cout<<"NO"<<endl;
return 0;
}
}
auto check=
[&](Int a,Int b){
if(!a&&!b) return;
auto in=[&](Int y,Int x){return 0<=y&&y<h&&0<=x&&x<w;};
Int used[100][100];
memset(used,0,sizeof(used));
for(Int i=0;i<h;i++){
for(Int j=0;j<w;j++){
if(used[i][j]||s[i][j]!='#') continue;
Int cnt=0;
while(in(i+cnt*a,j+cnt*b)&&s[i][j]==s[i+cnt*a][j+cnt*b]){
used[i+cnt*a][j+cnt*b]=1;
cnt++;
}
if(cnt&1) return;
}
}
cout<<"YES"<<endl;
exit(0);
};
for(Int a=-h;a<=h;a++)
for(Int b=-w;b<=w;b++)
check(a,b);
cout<<"NO"<<endl;
return 0;
}
beet