結果

問題 No.640 76本のトロンボーン
ユーザー merom686merom686
提出日時 2018-01-26 23:21:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,760 bytes
コンパイル時間 666 ms
コンパイル使用メモリ 75,880 KB
実行使用メモリ 5,272 KB
最終ジャッジ日時 2023-08-27 19:53:41
合計ジャッジ時間 1,528 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

int main() {
    int n;
    cin >> n;

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

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

        if (k == 7) break;
        if (k & 4) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < i; j++) {
                    swap(a[i][j], a[j][i]);
                }
            }
        }
        if (k & 2) {
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < n / 2; j++) {
                    swap(a[i][j], a[i][n - 1 - j]);
                }
            }
        }
        if (k & 1) {
            for (int i = 0; i < n / 2; i++) {
                for (int j = 0; j < n; j++) {
                    swap(a[i][j], a[n - 1 - i][j]);
                }
            }
        }
    }

    cout << m << endl;

    return 0;
}
0