結果
問題 | No.86 TVザッピング(2) |
ユーザー |
![]() |
提出日時 | 2019-12-13 19:50:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 72 ms / 5,000 ms |
コード長 | 2,087 bytes |
コンパイル時間 | 913 ms |
コンパイル使用メモリ | 114,460 KB |
実行使用メモリ | 7,844 KB |
最終ジャッジ日時 | 2025-06-20 14:00:10 |
合計ジャッジ時間 | 2,138 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 30 |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #include <time.h> #include <stack> #include <array> #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair<int, int> P; int s[110][110]; int count(int i, int j, int k, int l){ return s[j+1][l+1]-s[i][l+1]-s[j+1][k]+s[i][k]; } int main() { int n, m; cin>>n>>m; string a[110]; for(int i=0; i<n; i++) cin>>a[i]; int cnt=0; for(int i=0; i<n; i++) for(int j=0; j<m; j++) if(a[i][j]=='.') cnt++; for(int i=0; i<n; i++) for(int j=0; j<m; j++) s[i+1][j+1]=s[i][j+1]+s[i+1][j]-s[i][j]+(a[i][j]=='#'); for(int i=0; i<n; i++){ for(int j=i+1; j<n; j++){ for(int k=0; k<m; k++){ for(int l=k+1; l<m; l++){ if(2*(j-i)+2*(l-k)!=cnt) continue; for(int x=i; x<=j; x++){ for(int y=k; y<=l; y++){ if(x!=j && y!=l && count(x, x, k, y)==0 && count(i, x, y, y)==0 && count(i, i, y, l)==0 && count(i, j, l, l)==0 && count(j, j, k, l)==0 && count(x, j, k, k)==0){ cout<<"YES"<<endl; return 0; } if(x!=j && y!=k && count(i, x, y, y)==0 && count(x, x, y, l)==0 && count(x, j, l, l)==0 && count(j, j, k, l)==0 && count(i, j, k, k)==0 && count(i, i, k, y)==0){ cout<<"YES"<<endl; return 0; } if(x!=i && y!=l && count(x, x, k, y)==0 && count(x, j, y, y)==0 && count(j, j, y, l)==0 && count(i, j, l, l)==0 && count(i, i, k, l)==0 && count(i, x, k, k)==0){ cout<<"YES"<<endl; return 0; } if(x!=i && y!=k && count(x, j, y, y)==0 && count(x, x, y, l)==0 && count(i, x, l, l)==0 && count(i, i, k, l)==0 && count(i, j, k, k)==0 && count(j, j, k, y)==0){ cout<<"YES"<<endl; return 0; } } } } } } } cout<<"NO"<<endl; return 0; }