結果
問題 | No.1313 N言っちゃダメゲーム (4) |
ユーザー |
👑 ![]() |
提出日時 | 2020-12-10 00:23:48 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 26 ms / 2,000 ms |
コード長 | 865 bytes |
コンパイル時間 | 2,204 ms |
コンパイル使用メモリ | 196,856 KB |
最終ジャッジ日時 | 2025-01-16 21:02:44 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#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; }