結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー Mister
提出日時 2020-04-12 15:20:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 1,000 ms
コード長 1,014 bytes
コンパイル時間 797 ms
コンパイル使用メモリ 68,224 KB
最終ジャッジ日時 2025-01-09 17:43:30
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

constexpr int N = 42;

void solve() {
    int dmax;
    std::cin >> dmax;

    std::string s;
    s += std::string(14, 'x');

    for (int i = 0; i < 2; ++i) {
        std::string t;
        std::cin >> t;
        s += t;
    }

    s += std::string(14, 'x');

    int ans = 0;
    for (int d = 0; d <= dmax; ++d) {
        for (int si = 0; si < N; ++si) {
            int cont = 0, max = 0;
            bool valid = true;

            for (int i = 0; i < N; ++i) {
                if (s[i] == 'o' && (si <= i && i < si + d)) valid = false;
                if (s[i] == 'o' || (si <= i && i < si + d)) {
                    ++cont;
                } else {
                    cont = 0;
                }
                max = std::max(max, cont);
            }

            if (valid) ans = std::max(ans, max);
        }
    }

    std::cout << ans << std::endl;
}

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

    solve();

    return 0;
}
0