結果
| 問題 | 
                            No.179 塗り分け
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2019-07-12 16:29:10 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 973 bytes | 
| コンパイル時間 | 634 ms | 
| コンパイル使用メモリ | 67,824 KB | 
| 実行使用メモリ | 5,248 KB | 
| 最終ジャッジ日時 | 2024-11-17 18:24:34 | 
| 合計ジャッジ時間 | 2,206 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 WA * 1 | 
| other | AC * 21 WA * 19 | 
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:48:27: warning: ‘y’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   48 |                 if(x == W && y == H)
      |                    ~~~~~~~^~~~~~~~~
            
            ソースコード
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>
#include <math.h> 
#include <string>
using namespace std;
int main()
{
	int H, W;
	cin >> H >> W;
	int table[51][51];
	int cnt = 0;
	for(int i = 0 ; i < H ; ++i)
	{
		string s;
		cin >> s;
		for(int j = 0 ; j < W ; ++j)
		{
			table[i][j] = s.at(j)  == '#' ? 1 : 0;
			if(table[i][j]) ++cnt;
		}
	}
	if((cnt%2) != 0 || cnt ==0) 
	{
		cout << "NO";
		return 0;
	}
	for(int i = -W ; i < W ; ++i)for(int j = -H ; j < H ; ++j)
	{
		int m[51][51];
		for(int k = 0 ; k < W ; ++k)for(int l = 0 ; l < H ; ++l)
		{
			m[k][l] = table[k][l];
		}
		int x, y;
		for(x = 0 ; x < W ; ++x)for(y = 0 ; y < H ; ++y)
		{
			if(m[x][y] != 1) continue;
			if(x+i < W && y+j < H && x+i >= 0 && y+j >= 0 && m[x+i][y+j] == 1)
			{
				m[x][y] = 2;//red
				m[x+i][y+j] = 3;//blue
			}
			break;		
		}
		if(x == W && y == H)
		{
			cout << "YES";
			return 0;
		}
	}
    cout << "NO";
    return 0;
}