結果
| 問題 | 
                            No.640 76本のトロンボーン
                             | 
                    
| コンテスト | |
| ユーザー | 
                             TangentDay
                         | 
                    
| 提出日時 | 2018-01-26 23:24:38 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                            (最新)
                                AC
                                 
                             
                            (最初)
                            
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,764 bytes | 
| コンパイル時間 | 886 ms | 
| コンパイル使用メモリ | 89,288 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-06-22 04:19:35 | 
| 合計ジャッジ時間 | 1,531 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 14 WA * 1 | 
ソースコード
#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;
}
            
            
            
        
            
TangentDay