結果

問題 No.640 76本のトロンボーン
ユーザー KoshStormKoshStorm
提出日時 2018-02-14 18:29:08
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,305 bytes
コンパイル時間 1,951 ms
コンパイル使用メモリ 172,180 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-04 04:52:38
合計ジャッジ時間 2,763 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 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 2 ms
4,376 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 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define REP(i,n) for (long i=0;i<(n);i++)
#define FOR(i,a,b) for (long i=(a);i<(b);i++)
#define RREP(i,n) for(long i=n;i>=0;i--)
#define RFOR(i,a,b) for(long i=(a);i>(b);i--)
#define dump1d_arr(array) REP(i,array.size()) cerr << #array << "[" << (i) << "] ==> " << (array[i]) << endl;
#define dump2d_arr(array) REP(i,array.size()) REP(j,array[i].size()) cerr << #array << "[" << (i) << "]" << "[" << (j) << "] ==> " << (array[i][j]) << endl;
#define dump(x)  cerr << #x << " => " << (x) << endl;
#define CLR(vec) { REP(i,vec.size()) vec[i] = 0; } 
#define llINF (long long) 9223372036854775807
#define loINF (long) 2147483647
#define shINF (short) 32767
#define SORT(c) sort((c).begin(),(c).end())

using namespace std;
typedef vector<long> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<VB> VVB;

int main(void){
	short N;
	cin >> N;
	char arr[N][N];

	REP(i,N){
		REP(j,N){
			cin >> arr[i][j];
		}
	}

	// 横並べ。

	VVI count(2,VI(3,0));
	VB corner(4,false);

	REP(i,N){
		bool flg1 = true;
		bool flg2 = true;
		FOR(j,1,N-1){
			if (arr[i][j] != '.') flg1 = false;
			if (arr[j][i] != '.') flg2 = false;
		}

		if (i == 0) {
			corner[0] = (flg1 && (arr[i][0] == '.'||arr[i][N-1] == '.'));
			corner[1] = (flg2 && (arr[0][i] == '.'||arr[N-1][i] == '.'));
		}

		if (i == (N-1)){
			corner[2] = (flg1 && (arr[i][0] == '.'||arr[i][N-1] == '.'));
			corner[3] = (flg2 && (arr[0][i] == '.'||arr[N-1][i] == '.'));
		}

		if (flg1){
			if (arr[i][0] == '.') count[0][0]++;
			if (arr[i][N-1] == '.') count[0][2]++;
			if (arr[i][0] == '.'||arr[i][N-1] == '.') count[0][1]++;
		}

		if (flg2) {
			if (arr[0][i] == '.') count[1][0]++;
			if (arr[N-1][i] == '.') count[1][2]++;
			if (arr[0][i] == '.'||arr[N-1][i] == '.') count[1][1]++;
		}
	}

	long ans = max(count[0][1],count[1][1]);

	bool around = true;

	REP(i,N){
		if (!(arr[i][0] == '.'&& arr[i][N-1] == '.' && arr[0][i] == '.' && arr[N-1][i] == '.')) {
			around = false;
			break;
		}
	}
	if (around) ans = max(ans,(long)4);

	
	if (corner[0]) ans = max(ans,count[1][2]+1);
	if (corner[1]) ans = max(ans,count[0][2]+1);
	if (corner[2]) ans = max(ans,count[1][0]+1);
	if (corner[3]) ans = max(ans,count[0][0]+1);

	//dump2d_arr(count);
	//dump1d_arr(corner);
		

	cout << ans << endl;
	return 0;
}
0