結果

問題 No.86 TVザッピング(2)
ユーザー chocoruskchocorusk
提出日時 2019-12-13 19:50:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 2,087 bytes
コンパイル時間 913 ms
コンパイル使用メモリ 114,168 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-26 15:03:05
合計ジャッジ時間 2,383 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#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;
}
0