結果

問題 No.640 76本のトロンボーン
ユーザー mokomoko
提出日時 2018-02-24 11:00:51
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,783 bytes
コンパイル時間 1,565 ms
コンパイル使用メモリ 146,512 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-04 04:52:20
合計ジャッジ時間 2,361 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,384 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <math.h>
using namespace std;

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

typedef long long ll;
typedef pair<ll,int> P;
typedef pair<ll,P> PP;

//-----------------------------------------------------------------------------

void chmax(int &a,int b) { a=max(a,b); }

int n;
string s[75];
int r,l,u,b,tate,yoko,ans,R,L,U,B;

bool ok(int x,int y,int dir) {
	if(dir==0) {
		REP(i,n-1) if(s[y][x+i]=='#') return false;
		return true;
	}
	else {
		REP(i,n-1) if(s[y+i][x]=='#') return false;
		return true;
	}
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin>>n;
	REP(i,n) cin>>s[i];

	REP(i,n) yoko+=(int)(ok(0,i,0)||ok(1,i,0)); //横の合計
	REP(i,n) tate+=(int)(ok(i,0,1)||ok(i,1,1)); //縦の合計
	REP(i,n) l+=(int)ok(0,i,0); //左寄り
	REP(i,n) r+=(int)ok(1,i,0); //右寄り
	REP(i,n) u+=(int)ok(i,0,1); //上寄り
	REP(i,n) b+=(int)ok(i,1,1); //下寄り
	L=(int)(ok(0,0,1)||ok(0,1,1)); //1番左に縦に置く
	R=(int)(ok(n-1,0,1)||ok(n-1,1,1)); //1番右に縦に置く
	U=(int)(ok(0,0,0)||ok(1,0,0)); //1番上に横に置く
	B=(int)(ok(0,n-1,0)||ok(1,n-1,0)); //1番下に横に置く

	chmax(ans,yoko); //横だけ
	chmax(ans,tate); //縦だけ
	chmax(ans,l+R); //左寄り+1番右に縦
	chmax(ans,r+L); //右寄り+1番左に縦
	chmax(ans,u+B); //上寄り+1番下に横
	chmax(ans,b+U); //下寄り+1番上に横
	chmax(ans,(int)ok(0,0,0)+(int)ok(n-1,0,1)+(int)ok(1,n-1,0)+(int)ok(0,1,1)); //1番外側を囲む

	cout<<ans<<endl;

	return 0;
}
0