結果

問題 No.1313 N言っちゃダメゲーム (4)
ユーザー k
提出日時 2021-02-04 19:58:47
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 620 bytes
コンパイル時間 1,792 ms
コンパイル使用メモリ 197,652 KB
最終ジャッジ日時 2025-01-18 11:16:16
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define REP(i,n) for(int i=0; i<(int)(n); i++)

const int INF = 1<<30;

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

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

  string s;
  cin >> s;
  s = "o" + s;
  
  vector<bool> win(n);
  int lose = INF;
  for (int i = n-1; i >= 0; i--) {
    if (s[i] == 'x')
      win[i] = true;
    else {
      if (lose <= i + k)
        win[i] = true;
    }
    if (!win[i])
      lose = i;
  }

  if (!win[0])
    cout << 0 << endl;
  else {
    for (int i = 1; i <= k; i++)
      if (!win[i])
        cout << i << endl;
  }
  
  return 0;
}
0