結果

問題 No.86 TVザッピング(2)
ユーザー 沙耶花沙耶花
提出日時 2021-10-22 20:19:40
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,591 bytes
コンパイル時間 5,118 ms
コンパイル使用メモリ 269,524 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 09:47:50
合計ジャッジ時間 14,198 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 3 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 3 ms
4,348 KB
testcase_09 AC 988 ms
4,348 KB
testcase_10 AC 777 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 519 ms
4,348 KB
testcase_15 AC 601 ms
4,348 KB
testcase_16 AC 594 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 2 ms
4,348 KB
testcase_19 WA -
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 962 ms
4,348 KB
testcase_22 AC 3 ms
4,348 KB
testcase_23 AC 746 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 963 ms
4,348 KB
testcase_30 AC 2 ms
4,348 KB
testcase_31 AC 2 ms
4,348 KB
testcase_32 AC 2 ms
4,348 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()){
		rep(j,S[0].size()){
			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){
		//rep(j,S.size())cout<<S[j]<<endl;
		if(check(S)){
			cout<<"YES"<<endl;
			return 0;
		}
		//cout<<i<<endl;
		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