Submission #64782748


Source Code Expand

#line 2 "Library/src/debug.hpp"

#ifdef ONLINE_JUDGE
#define debug(x) void(0)
#else
#define _GLIBCXX_DEBUG
#include <iostream>
#define debug(x) \
    std::cerr << __LINE__ << " : " << #x << " = " << (x) << std::endl
#endif

/**
 * @brief Debugger
 */
#line 2 "Library/src/stream.hpp"
#include <ctype.h>
#include <stdio.h>
#include <string>
#line 2 "Library/src/internal/type_traits.hpp"
#include <iostream>
#include <limits>
#include <numeric>
#include <typeinfo>
#include <cstdint>

namespace kyopro {
namespace internal {
template <typename... Args> struct first_enabled {};

template <typename T, typename... Args>
struct first_enabled<std::enable_if<true, T>, Args...> {
    using type = T;
};
template <typename T, typename... Args>
struct first_enabled<std::enable_if<false, T>, Args...>
    : first_enabled<Args...> {};
template <typename T, typename... Args> struct first_enabled<T, Args...> {
    using type = T;
};

template <typename... Args>
using first_enabled_t = typename first_enabled<Args...>::type;

template <int dgt, std::enable_if_t<dgt <= 128>* = nullptr> struct int_least {
    using type = first_enabled_t<std::enable_if<dgt <= 8, std::int8_t>,
                                 std::enable_if<dgt <= 16, std::int16_t>,
                                 std::enable_if<dgt <= 32, std::int32_t>,
                                 std::enable_if<dgt <= 64, std::int64_t>,
                                 std::enable_if<dgt <= 128, __int128_t>>;
};

template <int dgt, std::enable_if_t<dgt <= 128>* = nullptr> struct uint_least {
    using type = first_enabled_t<std::enable_if<dgt <= 8, std::uint8_t>,
                                 std::enable_if<dgt <= 16, std::uint16_t>,
                                 std::enable_if<dgt <= 32, std::uint32_t>,
                                 std::enable_if<dgt <= 64, std::uint64_t>,
                                 std::enable_if<dgt <= 128, __uint128_t>>;
};

template <int dgt> using int_least_t = typename int_least<dgt>::type;
template <int dgt> using uint_least_t = typename uint_least<dgt>::type;

template <typename T>
using double_size_uint_t = uint_least_t<2 * std::numeric_limits<T>::digits>;

template <typename T>
using double_size_int_t = int_least_t<2 * std::numeric_limits<T>::digits>;

struct modint_base {};
template <typename T> using is_modint = std::is_base_of<modint_base, T>;
template <typename T> using is_modint_t = std::enable_if_t<is_modint<T>::value>;


// is_integral
template <typename T>
using is_integral_t =
    std::enable_if_t<std::is_integral_v<T> || std::is_same_v<T, __int128_t> ||
                   std::is_same_v<T, __uint128_t>>;
};  // namespace internal
};  // namespace kyopro

/**
 * @brief Type Traits
 * @see https://qiita.com/kazatsuyu/items/f8c3b304e7f8b35263d8
 */
#line 6 "Library/src/stream.hpp"

namespace kyopro {

inline void single_read(char& c) {
    c = getchar_unlocked();
    while (isspace(c)) c = getchar_unlocked();
}
template <typename T, internal::is_integral_t<T>* = nullptr>
inline void single_read(T& a) {
    a = 0;
    bool is_negative = false;
    char c = getchar_unlocked();
    while (isspace(c)) {
        c = getchar_unlocked();
    }
    if (c == '-') is_negative = true, c = getchar_unlocked();
    while (isdigit(c)) {
        a = 10 * a + (c - '0');
        c = getchar_unlocked();
    }
    if (is_negative) a *= -1;
}
template <typename T, internal::is_modint_t<T>* = nullptr>
inline void single_read(T& a) {
    long long x;
    single_read(x);
    a = T(x);
}
inline void single_read(std::string& str) noexcept {
    char c = getchar_unlocked();
    while (isspace(c)) c = getchar_unlocked();
    while (!isspace(c)) {
        str += c;
        c = getchar_unlocked();
    }
}
template<typename T>
inline void read(T& x) noexcept {single_read(x);}
template <typename Head, typename... Tail>
inline void read(Head& head, Tail&... tail) noexcept {
    single_read(head), read(tail...);
}

inline void single_write(char c) noexcept { putchar_unlocked(c); }
template <typename T, internal::is_integral_t<T>* = nullptr>
inline void single_write(T a) noexcept {
    if (!a) {
        putchar_unlocked('0');
        return;
    }
    if constexpr (std::is_signed_v<T>) {
        if (a < 0) putchar_unlocked('-'), a *= -1;
    }
    constexpr int d = std::numeric_limits<T>::digits10;
    char s[d + 1];
    int now = d + 1;
    while (a) {
        s[--now] = (char)'0' + a % 10;
        a /= 10;
    }
    while (now <= d) putchar_unlocked(s[now++]);
}
template <typename T, internal::is_modint_t<T>* = nullptr>
inline void single_write(T a) noexcept {
    single_write(a.val());
}
inline void single_write(const std::string& str) noexcept {
    for (auto c : str) {
        putchar_unlocked(c);
    }
}
template <typename T> inline void write(T x) noexcept { single_write(x); }
template <typename Head, typename... Tail>
inline void write(Head head, Tail... tail) noexcept {
    single_write(head);
    putchar_unlocked(' ');
    write(tail...);
}
template <typename... Args> inline void put(Args... x) noexcept {
    write(x...);
    putchar_unlocked('\n');
}
};  // namespace kyopro

/**
 * @brief Fast IO(高速入出力)
 */
#line 2 "Library/src/template.hpp"
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(x) std::begin(x), std::end(x)
#define popcount(x) __builtin_popcountll(x)
using i128 = __int128_t;
using ll = long long;
using ld = long double;
using graph = std::vector<std::vector<int>>;
using P = std::pair<int, int>;
constexpr int inf = std::numeric_limits<int>::max() / 2;
constexpr ll infl = std::numeric_limits<ll>::max() / 2;
const long double pi = acosl(-1);
constexpr int dx[] = {1, 0, -1, 0, 1, -1, -1, 1, 0};
constexpr int dy[] = {0, 1, 0, -1, 1, 1, -1, -1, 0};
template <typename T1, typename T2> constexpr inline bool chmax(T1& a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> constexpr inline bool chmin(T1& a, T2 b) {
    return a > b && (a = b, true);
}

/**
 * @brief Template
*/
#line 4 "a.cpp"
using namespace std;
using namespace kyopro;

int main() {
    int n, k;
    string s;
    read(n, k, s);

    vector dpl(n + 1, array<ll, 2>{-inf, -inf});
    dpl[0][0] = 0;

    rep(i, n) {
        if (s[i] == 'o') {
            dpl[i + 1][1] = dpl[i][0] + 1;
        } else if (s[i] == '.') {
            dpl[i + 1][0] = max(dpl[i][0], dpl[i][1]);
        } else {
            dpl[i + 1][0] = max(dpl[i][0], dpl[i][1]);
            dpl[i + 1][1] = dpl[i][0] + 1;
        }
    }

    vector dpr(n + 1, array<ll, 2>{-inf, -inf});

    dpr[n][0] = 0;

    for (int i = n - 1; i >= 0; --i) {
        if (s[i] == 'o') {
            dpr[i][1] = dpr[i + 1][0] + 1;
        } else if (s[i] == '.') {
            dpr[i][0] = max(dpr[i + 1][0], dpr[i + 1][1]);
        } else {
            dpr[i][0] = max(dpr[i + 1][0], dpr[i + 1][1]);
            dpr[i][1] = dpr[i + 1][0] + 1;
        }
    }

    rep(i, n) {
        if (s[i] != '?') {
            cout << s[i];
        } else {
            bool f0 =
                max(dpl[i][0], dpl[i][1]) + max(dpr[i + 1][0], dpr[i + 1][1]) >=
                k;

            bool f1 = dpl[i][0] + dpr[i + 1][0] >= k - 1;
            
            // cout << endl;
            // put("DEBUG", dpl[i][0], dpl[i][1]);
            // put("DEBUG", dpr[i + 1][0], dpr[i + 1][1]);

            if (f1 && f0) {
                cout << "?";
            } else if (f1) {
                cout << "o";
            } else if (f0) {
                cout << ".";
            } else {
                assert(0);
            }
        }
    }
    
    cout << endl;
}

Submission Info

Submission Time
Task D - Logical Filling
User AC2K
Language C++ 20 (gcc 12.2)
Score 0
Code Size 7892 Byte
Status WA
Exec Time 10 ms
Memory 9972 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 400
Status
AC × 3
AC × 33
WA × 10
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_00.txt, 01_random_01.txt, 01_random_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt, 01_random_35.txt, 01_random_36.txt, 01_random_37.txt, 01_random_38.txt, 01_random_39.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 1 ms 3424 KiB
00_sample_01.txt AC 1 ms 3644 KiB
00_sample_02.txt AC 1 ms 3360 KiB
01_random_00.txt AC 4 ms 5152 KiB
01_random_01.txt AC 10 ms 9492 KiB
01_random_02.txt AC 9 ms 9288 KiB
01_random_03.txt AC 1 ms 3536 KiB
01_random_04.txt AC 4 ms 5684 KiB
01_random_05.txt AC 5 ms 5936 KiB
01_random_06.txt AC 7 ms 8068 KiB
01_random_07.txt AC 7 ms 7908 KiB
01_random_08.txt AC 2 ms 3580 KiB
01_random_09.txt AC 8 ms 7912 KiB
01_random_10.txt AC 7 ms 9812 KiB
01_random_11.txt AC 7 ms 9872 KiB
01_random_12.txt AC 7 ms 9816 KiB
01_random_13.txt AC 7 ms 9776 KiB
01_random_14.txt AC 7 ms 9876 KiB
01_random_15.txt AC 7 ms 9768 KiB
01_random_16.txt AC 7 ms 9868 KiB
01_random_17.txt AC 7 ms 9784 KiB
01_random_18.txt AC 7 ms 9864 KiB
01_random_19.txt AC 7 ms 9876 KiB
01_random_20.txt AC 8 ms 9824 KiB
01_random_21.txt AC 6 ms 9444 KiB
01_random_22.txt AC 10 ms 9768 KiB
01_random_23.txt AC 1 ms 3480 KiB
01_random_24.txt AC 1 ms 3476 KiB
01_random_25.txt AC 1 ms 3452 KiB
01_random_26.txt AC 1 ms 3556 KiB
01_random_27.txt WA 9 ms 9772 KiB
01_random_28.txt WA 9 ms 9808 KiB
01_random_29.txt WA 9 ms 9832 KiB
01_random_30.txt WA 9 ms 9876 KiB
01_random_31.txt WA 10 ms 9828 KiB
01_random_32.txt WA 9 ms 9836 KiB
01_random_33.txt WA 9 ms 9972 KiB
01_random_34.txt WA 9 ms 9880 KiB
01_random_35.txt WA 9 ms 9776 KiB
01_random_36.txt WA 9 ms 9816 KiB
01_random_37.txt AC 10 ms 9824 KiB
01_random_38.txt AC 10 ms 9768 KiB
01_random_39.txt AC 10 ms 9788 KiB