結果

問題 No.640 76本のトロンボーン
ユーザー Lepton_sLepton_s
提出日時 2018-01-26 22:53:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 2,395 bytes
コンパイル時間 943 ms
コンパイル使用メモリ 120,128 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-27 22:59:31
合計ジャッジ時間 1,677 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,ll> PPI;
typedef pair<ll,P> PIP;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vp;
#define PQ(T) priority_queue<T,vector<T>,greater<T>>
#define PQ2(T) priority_queue<T>
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define REP(i,a,b) for(ll (i)=a;(i)<(ll)(b);++(i))
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n+1)
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(x,y) ((x)=min((x),(y)))
#define chmax(x,y) ((x)=max((x),(y)))
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
#define DEBUG(x) cerr<<"line ("<<__LINE__<<")  "<<#x<<": "<<x<<endl;
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N 80
string s[N];
int n;

void rot(){
	string t[N];
	rep(i, n) t[i] = (s[i]);
	rep(i, n) rep(j, n) s[i][j] = t[j][i];
}

int solve(){
	string a = string(n, '.'), b = string(n-1, '.')+"#", c = "#"+string(n-1, '.');
	int f = 3;
	int res = 0;
	rep(i, n){
		if(0<i&&i<n-1){
			if(s[i][0]=='#') f &= 1;
			if(s[i][n-1]=='#') f &= 2;
		}
		if(s[i]==a) res++;
		else if(s[i]==b||s[i]==c){
			res++;
			if(0<i&&i<n-1) f &= 0;
		}
	}
	int r = 0;
	if(f&2){
		if(s[0][0]=='.'&&s[0]!=b||s[n-1][0]=='.'&&s[n-1]!=b) r = 1;
	}
	if(f&1){
		if(s[0][n-1]=='.'&&s[0]!=c||s[n-1][n-1]=='.'&&s[n-1]!=c) r = 1;
	}
	res += r;
	return res;
}

int main(){
	cin>>n;
	rep(i, n) cin>>s[i];
	int res = solve();
	int t = 0;
	rot();
	chmax(res, solve());
	rep(i, n) if(s[i][0]=='#'||s[i][n-1]=='#'||s[0][i]=='#'||s[n-1][i]=='#') t = 1;
	if(t==0) chmax(res, 4);
	cout<<res<<endl;
	return 0;
}
0