結果

問題 No.640 76本のトロンボーン
ユーザー hogethoget
提出日時 2018-01-26 23:18:52
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,214 bytes
コンパイル時間 1,320 ms
コンパイル使用メモリ 146,668 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 22:59:45
合計ジャッジ時間 1,790 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 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,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 1 ms
4,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘bool ok(long long int)’:
main.cpp:54:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

string tmp[75];

bool chk(int x1,int y1,int x2,int y2){
	for(int i = x1;i <= x2;i++){
		for(int j = y1;j <= y2;j++){
			if(tmp[i][j] == '#') return false;
			else tmp[i][j] = '#';
		}
	}
	return true;
}

int n;

bool ok(int x){
	switch(x){
		case 0: return chk(0,0,n - 2,0);
		case 1: return chk(0,0,0,n - 2);
		case 2: return chk(1,0,n - 1,0);
		case 3: return chk(0,1,0,n - 1);
		case 4: return chk(n - 1,0,n - 1,n - 2);
		case 5: return chk(0,n - 1,n - 2,n - 1);
		case 6: return chk(n - 1,1,n - 1,n - 1);
		case 7: return chk(1,n - 1,n - 1,n - 1);
	}
}

signed main(){
	int ma = 0;
	string field[75];
	cin >> n;
	for(int i = 0;i < n;i++) cin >> field[i];
	for(int i = 0;i < (1 << 8);i++){
		int cnt = 0,t = 0;
		for(int i = 0;i < n;i++) tmp[i] = field[i];
		bool f = true;
		for(int j = 0;j < 8;j++){
			if((i >> j) & 1){
				t++;
				if(!ok(j)){
					f = false;
					break;
				}
			}
		}
		if(!f) continue;
		for(int j = 1;j < n - 1;j++){
			bool flag = true;
			for(int k = 1;k < n - 1;k++){
				if(tmp[j][k] == '#') flag = false;
			}
			if(flag && (tmp[j][0] == '.' || tmp[j][n - 1] == '.')) cnt++;
		}
		ma = max(ma,cnt + t);
		cnt = 0;
		for(int j = 1;j < n - 1;j++){
			bool flag = true;
			for(int k = 1;k < n - 1;k++){
				if(tmp[k][j] == '#') flag = false;
			}
			if(flag && (tmp[0][j] == '.' || tmp[n - 1][j] == '.')) cnt++;
		}
		ma = max(ma,cnt + t);
	}
	cout << ma << endl;
	return 0;
}
0