結果

問題 No.640 76本のトロンボーン
ユーザー merom686merom686
提出日時 2018-01-27 01:48:26
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 2,067 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 75,872 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-27 23:00:19
合計ジャッジ時間 1,506 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    char s[75][76];
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        for (int j = 0; j < n; j++) {
            s[i][j] = s[i][j] == '#';
        }
    }

    int r = 0;
    for (int l = 0; l < 8; l++) {
        if (l % 8 == 0) {
            // nop
        } else if (l % 4 == 0) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < i; j++) {
                    swap(s[i][j], s[j][i]);
                }
            }
        } else if (l % 2 == 0) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n / 2; j++) {
                    swap(s[i][j], s[i][n - 1 - j]);
                }
            }
        } else if (l % 1 == 0) {
            for (int i = 0; i < n / 2; i++) {
                for (int j = 0; j < n; j++) {
                    swap(s[i][j], s[n - 1 - i][j]);
                }
            }
        }

        int k[2] = {};
        for (int i = 0; i < n; i++) {
            int x = -1;
            for (int j = 0; j < n; j++) {
                if (s[i][j]) {
                    if (x < 0) {
                        x = j;
                    } else {
                        x = n;
                        break;
                    }
                }
            }
            if (x < 0 || x == 0 || x == n - 1) {
                k[0]++;
                if (i == 0 || x < 0) k[1]++;
            }
        }
        int b = 1;
        for (int i = 1; i < n; i++) {
            if (s[i][0]) {
                b = 0;
                break;
            }
        }
        r = max(r, max(k[0], k[1] + b));
    }

    int k = 4;
    for (int i = 0; i < n; i++) {
        if (s[i][0] || s[i][n - 1] || s[0][i] || s[n - 1][i]) {
            k = 0;
            break;
        }
    }
    r = max(r, k);

    cout << r << endl;

    return 0;
}
0