結果
| 問題 |
No.86 TVザッピング(2)
|
| コンテスト | |
| ユーザー |
沙耶花
|
| 提出日時 | 2021-10-22 20:21:28 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 946 ms / 5,000 ms |
| コード長 | 1,539 bytes |
| コンパイル時間 | 4,412 ms |
| コンパイル使用メモリ | 256,296 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2025-06-20 14:01:02 |
| 合計ジャッジ時間 | 10,602 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 30 |
ソースコード
#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;
}
沙耶花