結果

問題 No.640 76本のトロンボーン
ユーザー kotamanegikotamanegi
提出日時 2018-01-26 23:01:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,319 bytes
コンパイル時間 1,330 ms
コンパイル使用メモリ 127,168 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-08 15:21:09
合計ジャッジ時間 2,188 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define seg_size 524288
int grid[100][100] = {};
int n;
int tate_can_do(int x, int y) {
	if (x >= 2) return 0;
	for (int q = 0;q < n - 1;++q) {
		if (grid[x + q][y] == 1) return 0;
	}
	return 1;
}
int yoko_can_do(int x, int y) {
	if (y >= 2) return 0;
	for (int q = 0;q < n - 1;++q) {
		if (grid[x][y+q] == 1) return 0;
	}
	return 1;
}
int main() {
	cin >> n;
	REP(i, n) {
		string s;
		cin >> s;
		for (int q = 0;q < s.length();++q) {
			if (s[q] == '#') grid[i][q] = 1;
		}
	}
	long long ans = 0;
	for (int turn = 0;turn < 10;++turn) {
		if (tate_can_do(0, 0) == 1) {
			if (yoko_can_do(n - 1, 0) == 1) {
				long long tate = 0;
				for (int q = 1;q < n-1;++q) {
					tate += tate_can_do(0, q);
				}
				tate += max(tate_can_do(0, n - 1), tate_can_do(1, n - 1));
				long long yoko = 0;
				for (int q = 0;q < n - 1;++q) {
					yoko += yoko_can_do(q, 1);
				}
				ans = max({ ans,yoko+2,tate+2 });
			}
			if (yoko_can_do(n - 1, 1) == 1) {
				long long tate = 0;
				for (int q = 1;q < n;++q) {
					tate += tate_can_do(0, q);
				}
				long long yoko = 0;
				for (int q = 0;q < n - 1;++q) {
					yoko += yoko_can_do(q, 1);
				}
				ans = max({ ans,yoko+2,tate+2 });
			}
			long long tate = 0;
			for (int q = 1;q < n;++q) {
				tate += max(tate_can_do(0, q),tate_can_do(1,q));
			}
			long long yoko = 0;
			for (int q = 0;q < n - 1;++q) {
				yoko += yoko_can_do(q, 1);
			}
			ans = max({ ans,yoko+1,tate+1});
		}
		if (tate_can_do(1, 0) == 1) {
			if (yoko_can_do(n-1,1) == 1) {
				long long tate = 0;
				long long yoko = 0;
				for (int q = 1;q < n;++q) {
					tate += tate_can_do(0, q);
				}
				for (int q = 1;q < n - 1;++q) {
					yoko += yoko_can_do(q, 1);
				}
				yoko += max(yoko_can_do(0, 0), yoko_can_do(0, 1));
				ans = max({ ans,yoko + 2,tate + 2});
			}
			long long tate = 0;
			long long yoko = 0;
			for (int q = 1;q < n;++q) {
				tate += max(tate_can_do(0, q), tate_can_do(1, q));
			}
			for (int q = 1;q < n;++q) {
				yoko += yoko_can_do(q, 1);
			}
			yoko += max(yoko_can_do(0, 0), yoko_can_do(0, 1));
			ans = max({ ans,yoko + 1,tate + 1 });
		}
		long long tate = 0, yoko = 0;
		for (int q = 0;q < n;++q) {
			tate += max(tate_can_do(0, q),tate_can_do(1,q));
		}
		for (int q = 0;q < n;++q) {
			yoko += max(yoko_can_do(q,0),yoko_can_do(q, 1));
		}
		ans = max({ ans,yoko,tate });
		int copy_grid[100][100] = {};
		for (int t = 0;t < n;++t) {
			for (int q = 0;q < n;++q) {
				copy_grid[q][n-t-1] = grid[t][q];
			}
		}
		for (int t = 0;t < n;++t) {
			for (int q = 0;q < n;++q) {
				grid[t][q] = copy_grid[t][q];
			}
		}
	}
	cout << ans << endl;
	return 0;
}
0