結果

問題 No.640 76本のトロンボーン
ユーザー TangentDayTangentDay
提出日時 2018-01-26 23:24:38
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 1,764 bytes
コンパイル時間 1,350 ms
コンパイル使用メモリ 83,572 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-04 04:50:11
合計ジャッジ時間 1,775 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int calc2(vector<string> s){
    int n = s.size();
    REP(i,n-1) if (s[i][n-1] == '#') return 0;
    int ret = 1;
    REP(i,n){
        int ok = 1;
        REP(j,n-1) if (s[i][j] == '#') ok = 0;
        ret += ok;
    }
    return ret;
}

int calc(vector<string> s){
    int n = s.size();
    int ret = 0;
    REP(i,n){
        bool ok = true;
        FOR(j,1,n-2) if (s[i][j] == '#') ok = false;
        if (!ok) continue;
        if (s[i][0] == '.' || s[i][n-1] == '.') ret++;
    }

    ret = max(ret, calc2(s));
    reverse(ALL(s));
    ret = max(ret, calc2(s));
    reverse(ALL(s));

    REP(i,n) reverse(ALL(s[i]));
    ret = max(ret, calc2(s));
    reverse(ALL(s));
    ret = max(ret, calc2(s));

    bool ok = true;
    REP(i,n) if (s[i][0] == '#' || s[i][n-1] == '#') ok = false;
    REP(j,n) if (s[0][j] == '#' || s[n-1][j] == '#') ok = false;
    if (ok) ret = max(ret, 4);

    return ret;
}

int main() {
    int n;
    cin >> n;
    vector<string> s(n);
    REP(i,n) cin >> s[i];

    vector<string> t(n, string(n, '.'));
    REP(i,n){
        REP(j,n) t[i][j] = s[j][i];
    }

    cout << max(calc(s), calc(t)) << endl;
    
    return 0;
}
0