結果

問題 No.179 塗り分け
ユーザー Lepton_sLepton_s
提出日時 2015-04-06 00:15:15
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 16 ms / 3,000 ms
コード長 1,354 bytes
コンパイル時間 665 ms
コンパイル使用メモリ 78,536 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-30 20:36:25
合計ジャッジ時間 2,471 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 3 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 12 ms
4,376 KB
testcase_09 AC 12 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 10 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 2 ms
4,376 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 11 ms
4,376 KB
testcase_21 AC 13 ms
4,380 KB
testcase_22 AC 16 ms
4,380 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 12 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 AC 12 ms
4,376 KB
testcase_28 AC 2 ms
4,380 KB
testcase_29 AC 12 ms
4,376 KB
testcase_30 AC 6 ms
4,376 KB
testcase_31 AC 12 ms
4,376 KB
testcase_32 AC 4 ms
4,376 KB
testcase_33 AC 12 ms
4,376 KB
testcase_34 AC 3 ms
4,376 KB
testcase_35 AC 12 ms
4,376 KB
testcase_36 AC 2 ms
4,380 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 1 ms
4,380 KB
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 1 ms
4,380 KB
testcase_42 AC 2 ms
4,380 KB
testcase_43 AC 1 ms
4,380 KB
testcase_44 AC 3 ms
4,376 KB
testcase_45 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<25;
typedef pair<int,int> P;
typedef long long ll;
typedef unsigned long long ull;

int h, w;
string s[200];
string res[2] = {"NO", "YES"};

bool check(int dx, int dy){
	int g[60][60];
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			g[i][j] = s[i][j]=='#';
	for(int i = 0; i < h; i++){
		for(int j_ = 0; j_ < w; j_++){
			int j = dy<0?w-j_-1:j_;
			if(g[i][j]){
				int i2 = i+dx, j2 = j+dy;
				if(i2>=h || j2>=w || i2<0 || j2<0 || !g[i2][j2]) return false;
				g[i2][j2] = 0;
			}
		}
	}
	return true;
}

int main(){
	cin>>h>>w;
	for(int i = 0; i < h; i++) cin>>s[i];
	bool ok = false, ng = true;
	for(int i = 0; i < h; i++)
		for(int j = 0; j < w; j++)
			if(s[i][j]=='#') ng = false;
	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)){
				ok = true;
				i = h;
				break;
			}
		}
	}
	cout<<res[ok && !ng]<<endl;
	return 0;
}
0