結果

問題 No.640 76本のトロンボーン
ユーザー e869120e869120
提出日時 2018-01-26 22:38:41
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 2,000 ms
コード長 1,507 bytes
コンパイル時間 727 ms
コンパイル使用メモリ 83,984 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 22:59:14
合計ジャッジ時間 2,492 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <functional>
#include <cmath>
#include <tuple>
using namespace std;
#pragma warning (disable: 4996)

string S[76]; int n, maxn, cnt1, cnt2;

bool check(string V) {
	for (int i = 0; i < V.size(); i++) {
		if (V[i] == '#') return false;
	}
	return true;
}
int count() {
	int ret = 0;
	for (int i = 0; i < n; i++) {
		int F = 0;
		for (int j = 0; j < n; j++) {
			if (S[j][i] == '#') F = 0;
			else F++;
			if (F == n - 1) { ret++; F = 0; }
		}
	}
	return ret;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> S[i];
		for (int j = 0; j < S[i].size(); j++) { if (S[i][j] == '#')cnt1++; }
	}
	for (int i = 1; i < n - 1; i++) {
		for (int j = 1; j < n - 1; j++) { if (S[i][j] == '#')cnt2++; }
	}
	if (cnt1 == (n - 2)*(n - 2) && cnt2 == cnt1) { cout << "4" << endl; return 0; }
	for (int i = 0; i < 2; i++) {
		maxn = max(maxn, count());
		for (int j = 0; j < n; j++) {
			if (check(S[j].substr(0, n - 1)) == true) {
				for (int k = 0; k < n - 1; k++) S[j][k] = '#';
				maxn = max(maxn, count() + 1);
				for (int k = 0; k < n - 1; k++) S[j][k] = '.';
			}
			if (check(S[j].substr(1, n - 1)) == true) {
				for (int k = 1; k < n; k++) S[j][k] = '#';
				maxn = max(maxn, count() + 1);
				for (int k = 1; k < n; k++) S[j][k] = '.';
			}
		}

		for (int j = 0; j < n; j++) {
			for (int k = j + 1; k < n; k++) swap(S[j][k], S[k][j]);
		}
	}
	cout << maxn << endl;
	return 0;
}
0