結果

問題 No.640 76本のトロンボーン
ユーザー ミドリムシミドリムシ
提出日時 2018-01-26 23:50:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 3,599 bytes
コンパイル時間 762 ms
コンパイル使用メモリ 77,812 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 12:40:07
合計ジャッジ時間 2,455 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<string> space(N);
    for(int i = 0; i < N; i++){
        cin >> space[i];
    }
    int candidate_for_ans[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    for(int g = 0; g < 2; g++){
        for(int i = 0; i < 2; i++){
            for(int j = 0; j < N; j++){
                bool if_can_push_trombone = true;
                for(int k = !i; k < N - i; k++){
                    if(space[j][k] == '#'){
                        if_can_push_trombone = false;
                        break;
                    }
                }
                candidate_for_ans[i + g * 7] += if_can_push_trombone;
            }
            bool if_can_push_trombone_in_edge = true;
            for(int j = 1; j < N - 1; j++){
                if(space[j][i * (N - 1)] == '#'){
                    if_can_push_trombone_in_edge = false;
                    break;
                }
            }
            candidate_for_ans[i + g * 7] += if_can_push_trombone_in_edge * (space[i * (N - 1)][0] != '#' || space[i * (N - 1)][N - 1] != '#');
        }
        for(int h = 0; h < 2; h++){
            for(int i = 0; i < 2; i++){
                for(int j = !h; j < N - h; j++){
                    bool if_can_push_trombone = true;
                    for(int k = !i; k < N - i; k++){
                        if(space[j][k] == '#'){
                            if_can_push_trombone = false;
                            break;
                        }
                    }
                    candidate_for_ans[h * 2 + i + 2 + g * 7] += if_can_push_trombone;
                }
                bool if_can_push_trombone = true;
                for(int j = !h; j < N - h; j++){
                    if(space[h * (N - 1)][j] == '#'){
                        if_can_push_trombone = false;
                        break;
                    }
                }
                candidate_for_ans[h * 2 + i + 2 + g * 7] += if_can_push_trombone;
                bool if_can_push_trombone_in_edge = true;
                for(int j = !h; j < N - h; j++){
                    if(space[j][i * (N - 1)] == '#'){
                        if_can_push_trombone_in_edge = false;
                        break;
                    }
                }
                candidate_for_ans[h * 2 + i + 2 + g * 7] += if_can_push_trombone_in_edge;
            }
        }
        for(int i = 0; i < N; i++){
            bool if_can_push_trombone = true;
            for(int j = 1; j < N - 1; j++){
                if(space[i][j] == '#'){
                    if_can_push_trombone = false;
                    break;
                }
            }
            candidate_for_ans[6 + g * 7] += if_can_push_trombone * (space[i][0] != '#' || space[i][N - 1] != '#');
        }
        vector<string> new_space(N);
        for(int i = 0; i < N; i++){
            for(int j = 0; j < N; j++){
                new_space[i].push_back(space[j][i]);
            }
        }
        space = new_space;
    }
    int ans = 0;
    for(int i = 0; i < 14; i++){
        ans = max(ans, candidate_for_ans[i]);
    }
    bool if_can_push_trombone_in_4_edges = true;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(!i || !j || i == N - 1 || j == N - 1){
                if(space[i][j] == '#'){
                    if_can_push_trombone_in_4_edges = false;
                    break;
                }
            }
        }
    }
    cout << max(ans, if_can_push_trombone_in_4_edges * 4) << endl;
}

0