結果
| 問題 | 
                            No.179 塗り分け
                             | 
                    
| コンテスト | |
| ユーザー | 
                             latte0119
                         | 
                    
| 提出日時 | 2015-04-06 01:07:18 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 4 ms / 3,000 ms | 
| コード長 | 1,013 bytes | 
| コンパイル時間 | 565 ms | 
| コンパイル使用メモリ | 64,456 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-07-23 14:26:15 | 
| 合計ジャッジ時間 | 1,683 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 40 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:28:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   28 |     scanf("%d%d",&H,&W);
      |     ~~~~~^~~~~~~~~~~~~~
main.cpp:29:30: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   29 |     for(int i=0;i<H;i++)scanf("%s",fld[i]);
      |                         ~~~~~^~~~~~~~~~~~~
            
            ソースコード
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdio>
#include<map>
using namespace std;
char fld[50][51];
int H,W;
bool used[50][50];
bool check(int dy,int dx){
    fill_n(*used,2500,false);
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(fld[i][j]=='.'||used[i][j])continue;
            int ty=i+dy,tx=j+dx;
            if(ty>=H||tx>=W||ty<0||tx<0)return false;
            if(fld[ty][tx]=='.')return false;
            used[ty][tx]=true;
        }
    }
    return true;
}
int main(){
    scanf("%d%d",&H,&W);
    for(int i=0;i<H;i++)scanf("%s",fld[i]);
    int cnt=0;
    for(int i=0;i<H;i++)for(int j=0;j<W;j++)if(fld[i][j]=='#')cnt++;
    if(cnt&1||cnt==0){
        puts("NO");
        return 0;
    }
    for(int i=0;i<H;i++){
        for(int j=-W+1;j<W;j++){
            if(i==0&&j==0)continue;
            if(check(i,j)){
                puts("YES");
                return 0;
            }
        }
    }
    puts("NO");
    return 0;
}
            
            
            
        
            
latte0119