結果

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

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
using namespace std;
using ll = long long;

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

    int n, k;
    cin >> n >> k;

    string s;
    cin >> s;

    int o = 0;
    for (int i = n - 2; i >= 0; i--) {
        if (s[i] == 'o') {
            if (o) s[i] = 'x';
        }
        o += s[i] == 'o';
        o -= i + k < n - 1 ? s[i + k] == 'o' : 0;
    }

    int b = 0;
    for (int i = 0; i < k; i++) {
        if (s[i] == 'o') {
            cout << i + 1 << endl;
            b = 1;
        }
    }
    if (!b) {
        cout << 0 << endl;
    }

    return 0;
}
0