結果

問題 No.1770 N言っちゃダメゲーム (6)
ユーザー 👑 NachiaNachia
提出日時 2021-12-02 00:27:44
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 121 ms / 2,000 ms
コード長 1,639 bytes
コンパイル時間 1,014 ms
コンパイル使用メモリ 81,932 KB
実行使用メモリ 11,036 KB
最終ジャッジ日時 2023-09-18 10:05:39
合計ジャッジ時間 5,303 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 73 ms
7,012 KB
testcase_11 AC 74 ms
6,960 KB
testcase_12 AC 73 ms
7,016 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 1 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 3 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 3 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 4 ms
4,380 KB
testcase_26 AC 5 ms
4,380 KB
testcase_27 AC 4 ms
4,380 KB
testcase_28 AC 67 ms
7,012 KB
testcase_29 AC 26 ms
4,952 KB
testcase_30 AC 85 ms
10,352 KB
testcase_31 AC 24 ms
4,916 KB
testcase_32 AC 109 ms
10,684 KB
testcase_33 AC 97 ms
10,356 KB
testcase_34 AC 100 ms
10,380 KB
testcase_35 AC 104 ms
10,324 KB
testcase_36 AC 102 ms
10,372 KB
testcase_37 AC 107 ms
10,580 KB
testcase_38 AC 120 ms
10,644 KB
testcase_39 AC 120 ms
11,036 KB
testcase_40 AC 121 ms
10,584 KB
testcase_41 AC 121 ms
10,568 KB
testcase_42 AC 121 ms
10,592 KB
testcase_43 AC 105 ms
10,376 KB
testcase_44 AC 80 ms
10,104 KB
testcase_45 AC 103 ms
10,300 KB
testcase_46 AC 69 ms
6,948 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <atcoder/lazysegtree>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(n); i++)


namespace rq{
    using S = int;
    using F = int;
    S op(S l, S r){ return -1; }
    S e(){ return -1; }
    S mapping(F f, S x){
        if(x == -1) return f;
        if(f == -1) return x;
        if(f == x) return x;
        return -2;
    }
    S composition(F f, F x){
        if(x == -1) return f;
        if(f == -1) return x;
        if(f == x) return x;
        return -2;
    }
    F id(){ return -1; }
    using rq = atcoder::lazy_segtree<S,op,e,F,mapping,composition,id>;
}



int main(){
    int N,K; cin >> N >> K;

    if(K == 1){
        cout << "1\n";
        return 0;
    }

    rq::rq A(N+K+10);
    A.apply(N,N+K+10,-2);

    for(int i=N+K; i>=1; i--){
        int p = A.get(i);
        if(p == -2) continue;
        if(p == -1){
            A.apply(max(0,i-K), min(N,i), i);
            continue;
        }
        int nx = i + i - p;
        if(nx < 0) continue;
        A.apply(nx, nx+1, i);
    }

    // rep(i,N+1) cout << A.get(i) << " "; cout << endl;

    vector<int> ans;
    if(A.get(0) == -1) ans.push_back(0);
    for(int i=1; i<=K; i++){
        int f = A.get(i);
        if(f == -1) ans.push_back(i);
        else if(f == i * 2) ans.push_back(i);
    }
    for(auto a : ans) cout << a << "\n";
    return 0;
}




struct ios_do_not_sync {
    ios_do_not_sync() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;
0