結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー izryt(趣味)
提出日時 2016-01-14 05:20:59
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 819 bytes
コンパイル時間 558 ms
コンパイル使用メモリ 57,720 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 11:50:22
合計ジャッジ時間 1,915 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>

using namespace std;

int f(string a)
{
    a += "x";

    int ma = 0;
    
    bool st = true;
    int s;
    for (int i = 0; i < a.size(); ++i) {
        if (st && a[i] == 'o') {
            s = i;
            st = false;
        } else if (!st && a[i] == 'x') {
            ma = max(ma, i - s);
            st = true;
        }
    }

    return ma;
}

int main()
{
    int d; cin >> d;
    string a(14, 'x');

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

    int ma = 0;

    for (int i = 0; i <= s.size() - 14; ++i) {
        string t = s;
        for (int j = 0; j < d; ++j) {
            if (t[i+j] == 'x') t[i+j] = 'o';
            else break;
        }
        ma = max(ma, f(t));
    }

    cout << ma << endl;
}
0