結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-07-12 17:09:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,007 bytes |
| コンパイル時間 | 673 ms |
| コンパイル使用メモリ | 67,952 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-17 20:00:53 |
| 合計ジャッジ時間 | 2,138 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 WA * 1 |
| other | AC * 23 WA * 17 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:49:27: warning: ‘y’ may be used uninitialized in this function [-Wmaybe-uninitialized]
49 | 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[j][i] = s.at(j) == '#' ? 1 : 0;
if(table[j][i]) ++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)
{
if(i==0 && j == 0) continue;
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;
}