結果
| 問題 |
No.1313 N言っちゃダメゲーム (4)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-12-10 08:56:24 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 5,582 bytes |
| コンパイル時間 | 2,771 ms |
| コンパイル使用メモリ | 218,188 KB |
| 最終ジャッジ日時 | 2025-01-16 21:16:20 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 14 WA * 21 |
ソースコード
#include <bits/stdc++.h>
#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif
template <typename T, typename U>
bool chmin(T &a, const U &b){
return (a > b ? a = b, true : false);
}
template <typename T, typename U>
bool chmax(T &a, const U &b){
return (a < b ? a = b, true : false);
}
template <typename T, size_t N, typename U>
void fill_array(T (&a)[N], const U &v){
std::fill((U*)a, (U*)(a + N), v);
}
template <typename T, size_t N, size_t I = N>
auto make_vector(const std::array<int, N> &a, T value = T()){
static_assert(I >= 1);
static_assert(N >= 1);
if constexpr (I == 1){
return std::vector<T>(a[N - I], value);
}else{
return std::vector(a[N - I], make_vector<T, N, I - 1>(a, value));
}
}
template <typename T>
std::ostream& operator<<(std::ostream &s, const std::vector<T> &a){
for(auto it = a.begin(); it != a.end(); ++it){
if(it != a.begin()) s << " ";
s << *it;
}
return s;
}
template <typename T>
std::istream& operator>>(std::istream &s, std::vector<T> &a){
for(auto &x : a) s >> x;
return s;
}
std::string YesNo(bool value){return value ? "Yes" : "No";}
std::string YESNO(bool value){return value ? "YES" : "NO";}
std::string yesno(bool value){return value ? "yes" : "no";}
template <typename T>
void putl(const T &value){
std::cout << value << "\n";
}
template <typename Head, typename ... Tail>
void putl(const Head head, const Tail &... tail){
std::cout << head << " ";
putl(tail ...);
}
namespace haar_lib {
class integer_set {
std::map<int64_t, int64_t> data_;
using citer = typename std::map<int64_t, int64_t>::const_iterator;
std::optional<citer> get_interval(int64_t x) const {
if(data_.empty()) return std::nullopt;
auto next = data_.lower_bound(x);
if(next == data_.end()){
auto prev = std::prev(next);
if(x <= prev->second) return {prev};
return std::nullopt;
}
if(next->first == x) return {next};
if(next == data_.begin()) return std::nullopt;
auto prev = std::prev(next);
if(x <= prev->second) return {prev};
return std::nullopt;
}
public:
integer_set(){}
bool contains(int64_t x) const {
return (bool)get_interval(x);
}
void add(int64_t x){
if(data_.empty()){
data_[x] = x;
return;
}
auto next = data_.lower_bound(x);
if(next == data_.end()){
auto prev = std::prev(next);
if(x <= prev->second) return;
if(prev->second + 1 == x){
prev->second = x;
}else{
data_[x] = x;
}
return;
}
if(next->first == x) return;
if(next == data_.begin()){
if(x + 1 == next->first){
auto t = next->second;
data_.erase(next);
data_[x] = t;
}else{
data_[x] = x;
}
return;
}
auto prev = std::prev(next);
if(x <= prev->second) return;
if(prev->second + 1 == x){
prev->second = x;
if(prev->second + 1 == next->first){
prev->second = next->second;
data_.erase(next);
}
}else if(x + 1 == next->first){
auto t = next->second;
data_.erase(next);
data_[x] = t;
}else{
data_[x] = x;
}
return;
}
void erase(int64_t x){
const auto res = get_interval(x);
if(res){
const auto it = res.value();
const auto [l, r] = *it;
data_.erase(it);
if(l <= x - 1) data_[l] = x - 1;
if(x + 1 <= r) data_[x + 1] = r;
}
}
int64_t mex(int64_t x) const {
auto res = get_interval(x);
if(res) return (*res)->second + 1;
return x;
}
};
};
namespace haar_lib {
template <typename Iter>
std::string join(Iter first, Iter last, std::string delim = " "){
std::stringstream s;
for(auto it = first; it != last; ++it){
if(it != first) s << delim;
s << *it;
}
return s.str();
}
}
namespace haar_lib {}
namespace solver {
using namespace haar_lib;
constexpr int m1000000007 = 1000000007;
constexpr int m998244353 = 998244353;
void init(){
std::cin.tie(0);
std::ios::sync_with_stdio(false);
std::cout << std::fixed << std::setprecision(12);
std::cerr << std::fixed << std::setprecision(12);
std::cin.exceptions(std::ios_base::failbit);
}
void solve(){
int N, K; std::cin >> N >> K;
std::string S; std::cin >> S;
std::vector<bool> danger(N + 1);
for(int i = 1; i <= N - 1; ++i){
danger[i] = S[i - 1] == 'x';
}
danger[N] = true;
dump(danger);
std::vector<int> g(N + 1);
integer_set iset;
std::map<int, int> count;
for(int i = N; i >= 0; --i){
if(i + K + 1 <= N){
count[g[i + K + 1]] -= 1;
if(count[g[i + K + 1]] == 0){
iset.erase(g[i + K + 1]);
}
}
if(danger[i]){
g[i] = 0;
}else{
g[i] = iset.mex(0);
}
iset.add(g[i]);
count[g[i]] += 1;
}
dump(g);
std::vector<int> ans;
for(int i = 1; i <= K; ++i){
if(g[i + 1] == 0) ans.push_back(i);
}
if(ans.empty()){
std::cout << 0 << "\n";
}else{
std::cout << join(ans.begin(), ans.end()) << "\n";
}
}
}
int main(){
solver::init();
while(true){
try{
solver::solve();
std::cout << std::flush;
std::cerr << std::flush;
}catch(const std::istream::failure &e){
break;
}catch(...){
break;
}
}
return 0;
}