結果

問題 No.1313 N言っちゃダメゲーム (4)
ユーザー 👑 NachiaNachia
提出日時 2020-12-10 00:23:48
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 865 bytes
コンパイル時間 2,235 ms
コンパイル使用メモリ 205,904 KB
実行使用メモリ 7,764 KB
最終ジャッジ日時 2023-10-19 10:41:55
合計ジャッジ時間 3,586 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 9 ms
7,764 KB
testcase_14 AC 8 ms
7,764 KB
testcase_15 AC 28 ms
7,764 KB
testcase_16 AC 28 ms
7,764 KB
testcase_17 AC 10 ms
5,716 KB
testcase_18 AC 20 ms
5,716 KB
testcase_19 AC 19 ms
5,648 KB
testcase_20 AC 4 ms
4,348 KB
testcase_21 AC 12 ms
4,592 KB
testcase_22 AC 10 ms
4,556 KB
testcase_23 AC 12 ms
5,648 KB
testcase_24 AC 3 ms
4,348 KB
testcase_25 AC 14 ms
5,716 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 7 ms
4,592 KB
testcase_28 AC 18 ms
5,716 KB
testcase_29 AC 18 ms
5,716 KB
testcase_30 AC 20 ms
7,764 KB
testcase_31 AC 18 ms
5,716 KB
testcase_32 AC 20 ms
7,764 KB
testcase_33 AC 8 ms
5,716 KB
testcase_34 AC 8 ms
5,716 KB
testcase_35 AC 9 ms
7,764 KB
testcase_36 AC 8 ms
5,716 KB
testcase_37 AC 9 ms
7,764 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using LL=long long;
using ULL=unsigned long long;
#define rep(i,n) for(int i=0;i<(n);i++)

struct segtree{
  int N;
  vector<int> V;
  segtree(int n){
    N=1; while(N<n) N*=2;
    V.assign(N*2,0);
  }
  void add(int p){
    p+=N; V[p]++;
    while(p!=1){ p/=2; V[p]++; }
  }
  int sum(int l,int r){
    int ans=0;
    l+=N; r+=N;
    while(l<r){
      if(l&1) ans+=V[l++];
      if(r&1) ans+=V[--r];
      l/=2; r/=2;
    }
    return ans;
  }
};

int main(){
  int N,K; cin>>N>>K;
  segtree G(N+K);
  string S; cin>>S;
  vector<int> ans;
  for(int i=N-1; i>=1; i--){
    if(S[i-1]!='x'){
      if(G.sum(i+1,i+K+1)==0){
        G.add(i);
        if(1<=i && i<=K) ans.push_back(i);
      }
    }
  }

  if(ans.empty()) cout<<0<<endl;
  else{ reverse(ans.begin(),ans.end()); for(int a:ans) cout<<a<<endl; }
  return 0;
}
0