結果
| 問題 |
No.179 塗り分け
|
| コンテスト | |
| ユーザー |
tetsuzuki1115
|
| 提出日時 | 2018-02-28 17:52:51 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 10 ms / 3,000 ms |
| コード長 | 1,588 bytes |
| コンパイル時間 | 1,057 ms |
| コンパイル使用メモリ | 96,524 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-23 14:46:16 |
| 合計ジャッジ時間 | 2,572 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 40 |
ソースコード
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;
long long MOD = 1000000007;
int H,W;
vector<string> V;
struct Point {
Point(){};
Point( int a, int b ) { x = a; y = b; };
int x;
int y;
};
bool isOK( int x, int y ) {
return x >= 0 && y >= 0 && x < W && y < H;
}
bool func( int dx, int dy ) {
vector<string> T(H);
for ( int i = 0; i < H; i++ ) {
T[i] = V[i];
}
for ( int y = 0; y < H; y++ ) {
for ( int x = 0; x < W; x++ ) {
if ( T[y][x] == '#' ) {
if ( isOK(x+dx,y+dy) && T[y+dy][x+dx] == '#' ) {
T[y+dy][x+dx] = '.';
continue;
}
if ( isOK(x-dx,y-dy) && T[y-dy][x-dx] == '#' ) {
T[y-dy][x-dx] = '.';
continue;
}
return false;
}
}
}
return true;
}
int main() {
cin >> H >> W;
V.resize(H);
for ( int i = 0; i < H; i++ ) {
cin >> V[i];
}
vector<Point> P;
for ( int y = 0; y < H; y++ ) {
for ( int x = 0; x < W; x++ ) {
if ( V[y][x] == '#' ) {
Point p(x,y);
P.push_back( p );
}
}
}
bool ans = false;
for ( int i = 1; i < P.size(); i++ ) {
if ( func( P[0].x-P[i].x, P[0].y-P[i].y ) ) { ans = true; }
}
cout << ( ans ? "YES" : "NO" ) << endl;
return 0;
}
tetsuzuki1115