結果

問題 No.204 ゴールデン・ウィーク(2)
ユーザー karinohito
提出日時 2024-09-11 16:32:37
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 692 bytes
コンパイル時間 2,132 ms
コンパイル使用メモリ 196,064 KB
最終ジャッジ日時 2025-02-24 06:40:14
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int cnt(string S){
    int k=0,res=0;
    for(auto s:S){
        if(s=='o')k++;
        else{
            res=max(res,k);
            k=0;
        }
    }
    return max(res,k);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int D;
    cin>>D;
    string S,T;
    cin>>S>>T;
    for(int i=0;i<14;i++){
        S="x"+S;
        T=T+"x";
    }
    S+=T;
    int an=cnt(S);
    if(D!=0)for(int i=0;i<S.size()-D+1;i++){
        string NS=S;
        for(int j=i;j<i+D;j++){
            if(NS[j]=='o')break;
            NS[j]='o';
        }
        an=max(an,cnt(NS));
    }
    cout<<an<<endl;

}
0