結果
| 問題 | 
                            No.1770 N言っちゃダメゲーム (6)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             Nachia
                         | 
                    
| 提出日時 | 2021-12-02 00:27:44 | 
| 言語 | C++17(gcc12)  (gcc 12.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 119 ms / 2,000 ms | 
| コード長 | 1,639 bytes | 
| コンパイル時間 | 3,175 ms | 
| コンパイル使用メモリ | 129,172 KB | 
| 最終ジャッジ日時 | 2025-01-26 02:44:17 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 44 | 
ソースコード
#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;
            
            
            
        
            
Nachia