結果

問題 No.640 76本のトロンボーン
ユーザー mokomoko
提出日時 2018-02-24 10:54:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,542 bytes
コンパイル時間 1,445 ms
コンパイル使用メモリ 160,312 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-21 00:20:18
合計ジャッジ時間 2,674 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 WA -
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 1 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,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;

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); //下寄り

	chmax(ans,yoko); //横だけ
	chmax(ans,tate); //縦だけ
	chmax(ans,l+(int)(ok(n-1,0,1)||ok(n-1,1,1))); //左寄り+1番右に縦
	chmax(ans,r+(int)(ok(0,0,1)||ok(0,1,1))); //右寄り+1番左に縦
	chmax(ans,u+(int)(ok(0,n-1,0)||ok(1,n-1,0))); //上寄り+1番下に横
	chmax(ans,b+(int)(ok(0,0,0)||ok(1,0,0))); //下寄り+1番上に横

	cout<<ans<<endl;

	return 0;
}
0