結果
問題 |
No.86 TVザッピング(2)
|
ユーザー |
![]() |
提出日時 | 2021-10-22 20:18:18 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,518 bytes |
コンパイル時間 | 4,504 ms |
コンパイル使用メモリ | 256,392 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-20 14:00:46 |
合計ジャッジ時間 | 10,745 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 26 WA * 4 |
ソースコード
#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()); } 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; }