結果

問題 No.1313 N言っちゃダメゲーム (4)
ユーザー penguinman
提出日時 2020-12-10 00:36:00
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 474 bytes
コンパイル時間 2,220 ms
コンパイル使用メモリ 194,540 KB
最終ジャッジ日時 2025-01-16 21:05:36
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 2
other AC * 14 WA * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K; cin>>N>>K;
    string S; cin>>S;
    int last=N-1;
    for(int i=N-1;i>=0;i--){
        if(S[i]=='o') {last=i;break;}
    }
    int cnt=0;
    S="o"+S;
    for(int i=0;i<N;i++){
        if(S[i]=='x') cnt++;
        else cnt=0;
        if(cnt==K){
            last=cnt-K;
            break;
        }
    }
    for(int i=N-1;i>=0;i--){
        if(last-i>K&&S[i]=='o') last=i;
    }
    cout<<last<<endl;
}
0