結果

問題 No.86 TVザッピング(2)
ユーザー 沙耶花沙耶花
提出日時 2021-10-22 20:21:28
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,370 ms / 5,000 ms
コード長 1,539 bytes
コンパイル時間 4,147 ms
コンパイル使用メモリ 267,060 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-26 15:04:37
合計ジャッジ時間 13,980 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,360 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1,370 ms
4,376 KB
testcase_10 AC 1,091 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,384 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 729 ms
4,376 KB
testcase_15 AC 825 ms
4,380 KB
testcase_16 AC 829 ms
4,380 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 1,336 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1,031 ms
4,380 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 1 ms
4,380 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1,352 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 100000000000000000

vector<string> get(int h,int w,int hh,int ww){
	//cout<<h<<','<<w<<','<<hh<<','<<ww<<endl;
	vector<string> ret(h,string(w,'.'));
	rep(i,h){
		rep(j,w){
			if(i!=0&&i!=h-1&&j!=0&&j!=w-1)ret[i][j] = '#';
		}
	}
	rep(i,hh){
		rep(j,ww){
			ret[i][j] = '#';
			ret[i+1][j] = '.';
			ret[i+1][j+1] = '.';
			ret[i][j+1] = '.';
		}
	}
	return ret;
}

bool check(vector<string> S){
	rep(i,S.size()-1){
		rep(j,S[0].size()-1){
			auto r = get(S.size(),S[0].size(),i,j);
			if(r==S)return true;
		}
	}
	//cout<<'a'<<endl;
	return false;
}

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<string> S(N);
	rep(i,N)cin>>S[i];
	
	while(S.back() == string(M,'#'))S.pop_back();
	while(S[0] == string(M,'#'))S.erase(S.begin());
	
	while(true){
		bool f = true;
		rep(i,S.size()){
			if(S[i].back()!='#')f = false;
		}
		if(!f)break;
		rep(i,S.size())S[i].pop_back();
	}
	while(true){
		bool f = true;
		rep(i,S.size()){
			if(S[i][0]!='#')f = false;
		}
		if(!f)break;
		rep(i,S.size())S[i].erase(S[i].begin());
	}
	
	if(S.size()==1 || S[0].size()==1){
		cout<<"NO"<<endl;
		return 0;
	}
	
	rep(i,4){
		if(check(S)){
			cout<<"YES"<<endl;
			return 0;
		}
		vector<string> temp(S[0].size(),"");
		rep(j,S.size()){
			rep(k,S[j].size()){
				temp[k] += S[S.size()-1-j][k];
			}
		}
		swap(S,temp);
	}
	
	cout<<"NO"<<endl;
	
	return 0;
}
0