結果

問題 No.1313 N言っちゃダメゲーム (4)
ユーザー momoharamomohara
提出日時 2020-12-10 15:40:25
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 6 ms / 2,000 ms
コード長 3,111 bytes
コンパイル時間 1,978 ms
コンパイル使用メモリ 203,628 KB
実行使用メモリ 6,752 KB
最終ジャッジ日時 2023-10-20 00:45:42
合計ジャッジ時間 3,313 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 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 5 ms
6,752 KB
testcase_14 AC 5 ms
6,752 KB
testcase_15 AC 6 ms
6,752 KB
testcase_16 AC 5 ms
5,960 KB
testcase_17 AC 4 ms
5,168 KB
testcase_18 AC 4 ms
5,300 KB
testcase_19 AC 4 ms
5,036 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 3 ms
4,348 KB
testcase_22 AC 3 ms
4,348 KB
testcase_23 AC 3 ms
4,772 KB
testcase_24 AC 3 ms
4,348 KB
testcase_25 AC 4 ms
5,300 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 4 ms
5,168 KB
testcase_29 AC 4 ms
5,432 KB
testcase_30 AC 5 ms
5,960 KB
testcase_31 AC 4 ms
5,432 KB
testcase_32 AC 5 ms
5,960 KB
testcase_33 AC 4 ms
5,168 KB
testcase_34 AC 4 ms
5,168 KB
testcase_35 AC 5 ms
6,488 KB
testcase_36 AC 4 ms
5,432 KB
testcase_37 AC 5 ms
5,696 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define all(hoge) (hoge).begin(), (hoge).end()
#define en '\n'
using ll = long long;
using ull = unsigned long long;
#define rep(i, m, n) for(ll i = (ll)(m); i < (ll)(n); ++i)
#define rep2(i, m, n) for(ll i = (ll)(n)-1; i >= (ll)(m); --i)
#define REP(i, n) rep(i, 0, n)
#define REP2(i, n) rep2(i, 0, n)
template<class T> using vec = vector<T>;
template<class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
using tp = tuple<ll, ll, ll>;

constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
//constexpr long long MOD = 998244353LL;
using ld = long double;
static const ld pi = 3.141592653589793L;

using Array = vector<ll>;
using Matrix = vector<Array>;

/*
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
*/

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T, typename F>
class SegmentTree {
private:
    T e;
    F op;
    ll n;
    vector<T> dat;

public:
    SegmentTree(F f, T _e, vector<T> v) : op(f), e(_e) {
        int _n = v.size();
        n = 1;
        while (n < _n)
            n *= 2;
        dat.resize(2 * n - 1, e);
        REP(i, _n)dat[n + i - 1] = v[i];
        for (int i = n - 2; i >= 0; i--)
            dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
    }

    SegmentTree(F f, T _e, int _n) : op(f), e(_e) {
        n = 1;
        while (n < _n)
            n *= 2;
        dat.resize(2 * n - 1, e);
        for (int i = n - 2; i >= 0; i--)
            dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
    }

    void update(int i, T x) {
        i += n - 1;
        dat[i] = x;
        while (i > 0) {
            i = (i - 1) / 2;
            dat[i] = op(dat[i * 2 + 1], dat[i * 2 + 2]);
        }
    }

    T get(int i) {
        i += n - 1;
        return dat[i];
    }

    T query(int l, int r) {
        //[l,r)でのクエリ処理
        T left = e, right = e;
        l += n - 1;
        r += n - 1;
        while (l < r) {
            if ((l & 1) == 0)
                left = op(left, dat[l]);
            if ((r & 1) == 0)
                right = op(dat[r - 1], right);
            l = l / 2;
            r = (r - 1) / 2;
        }
        return op(left, right);
    }
};


void solve() {
    ll n, k;
    string s;
    cin >> n >> k >> s;
    vec<ll> grundy(n + k + 1, 0);

    ll con=0;//相手が勝てる状態の数
    REP2(i,n){
        grundy[i] = (s[i]=='o' and con == 0);//一個でも相手が勝てる遷移があると選びたくない
        con -= grundy[i+k];
        con += grundy[i];
    }
    if(con == 0) cout<<0<<en;
    REP(i,min(n,k)){
        if(grundy[i]) cout<<i+1<<en;
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*
    ll t;
    cin >> t;
    REP(i, t - 1) {
        solve();
    }*/

    solve();

    return 0;
}
0