結果
| 問題 | No.179 塗り分け |
| コンテスト | |
| ユーザー |
goodbaton
|
| 提出日時 | 2015-04-08 22:43:37 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 172 ms / 3,000 ms |
| コード長 | 1,329 bytes |
| コンパイル時間 | 567 ms |
| コンパイル使用メモリ | 71,908 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-23 14:28:34 |
| 合計ジャッジ時間 | 3,311 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:50:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
50 | scanf("%d%d",&h,&w);
| ~~~~~^~~~~~~~~~~~~~
main.cpp:53:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
53 | scanf("%s",in[i]);
| ~~~~~^~~~~~~~~~~~
ソースコード
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
using namespace std;
typedef long long ll;
char in[50][51];
int h,w;
bool check(int x,int y){
bool kaku[50][50] = {0};
int c=0;
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(!kaku[i][j] && in[i][j]=='#'){
if(0<=h && 0<=w && i+y<h && j+x<w && in[i+y][j+x]=='#' && kaku[i+y][j+x]==false){
kaku[i+y][j+x]=true;
kaku[i][j]=true;
c++;
}
}
}
}
for(int i=0;i<h;i++){
for(int j=0;j<w;j++){
if(in[i][j]=='#' && !kaku[i][j]){
return false;
}
}
}
if(c==0) return false;
return true;
}
int main(){
scanf("%d%d",&h,&w);
for(int i=0;i<h;i++){
scanf("%s",in[i]);
}
for(int i=-w+1;i<w;i++){
for(int j=-h+1;j<h;j++){
if(i==0 && j==0) continue;
if(check(i,j)){
puts("YES");
return 0;
}
}
}
puts("NO");
return 0;
}
goodbaton