結果

問題 No.640 76本のトロンボーン
ユーザー chocoruskchocorusk
提出日時 2019-09-04 12:07:42
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,458 bytes
コンパイル時間 806 ms
コンパイル使用メモリ 102,328 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 23:01:41
合計ジャッジ時間 1,560 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 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>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n;
string s[77];
bool check(int p, int x, int y){
	if(p==0){
		if(y>=2) return false;
		for(int i=0; i<n-1; i++){
			if(s[x][y+i]=='#') return false;
		}
		return true;
	}else{
		if(x>=2) return false;
		for(int i=0; i<n-1; i++){
			if(s[x+i][y]=='#') return false;
		}
		return true;
	}
}
int main()
{
	cin>>n;
	for(int i=0; i<n; i++){
		cin>>s[i];
	}
	int ans=0;
	for(int i=0; i<(1<<8); i++){
		bool dame=0;
		for(int j=0; j<4; j++){
			if((i&(1<<(2*j))) && (i&(1<<(2*j+1)))){
				dame=1; break;
			}
		}
		P nuee[4]={P(0, 4), P(1, 6), P(2, 5), P(3, 7)};
		for(int j=0; j<4; j++){
			if((i&(1<<nuee[j].first)) && (i&(1<<nuee[j].second))){
				dame=1; break;
			}
		}
		if(dame) continue;
		int cnt=0;
		if(i&(1<<0)){
			if(check(0, 0, 0)) cnt++;
		}
		if(i&(1<<1)){
			if(check(0, 0, 1)) cnt++;
		}
		if(i&(1<<2)){
			if(check(0, n-1, 0)) cnt++;
		}
		if(i&(1<<3)){
			if(check(0, n-1, 1)) cnt++;
		}
		if(i&(1<<4)){
			if(check(1, 0, 0)) cnt++;
		}
		if(i&(1<<5)){
			if(check(1, 1, 0)) cnt++;
		}
		if(i&(1<<6)){
			if(check(1, 0, n-1)) cnt++;
		}
		if(i&(1<<7)){
			if(check(1, 1, n-1)) cnt++;
		}
		int cnt1=0, cnt2=0;
		if((i&(1<<0))==0 && ((i&(1<<1)))==0 && (i&(1<<2))==0 && ((i&(1<<3)))==0){
			for(int j=1; j<n-1; j++){
				if(check(1, 0, j) || check(1, 1, j)) cnt1++;
			}
		}else if((i&(1<<2))==0 && ((i&(1<<3)))==0){
			for(int j=1; j<n-1; j++){
				if(check(1, 1, j)) cnt1++;
			}
		}else if((i&(1<<0))==0 && ((i&(1<<1)))==0){
			for(int j=1; j<n-1; j++){
				if(check(1, 0, j)) cnt1++;
			}
		}
		if((i&(1<<4))==0 && ((i&(1<<5)))==0 && (i&(1<<6))==0 && ((i&(1<<7)))==0){
			for(int j=1; j<n-1; j++){
				if(check(0, j, 0) || check(0, j, 1)) cnt2++;
			}
		}else if((i&(1<<6))==0 && ((i&(1<<7)))==0){
			for(int j=1; j<n-1; j++){
				if(check(0, j, 1)) cnt2++;
			}
		}else if((i&(1<<4))==0 && ((i&(1<<5)))==0){
			for(int j=1; j<n-1; j++){
				if(check(0, j, 0)) cnt2++;
			}
		}
		ans=max({ans, cnt+cnt1, cnt+cnt2});
	}
	cout<<ans<<endl;
	return 0;
}
0