結果
| 問題 | No.3251 kthmex | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-08-07 00:21:48 | 
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                TLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,349 bytes | 
| コンパイル時間 | 2,418 ms | 
| コンパイル使用メモリ | 203,120 KB | 
| 実行使用メモリ | 7,712 KB | 
| 最終ジャッジ日時 | 2025-08-07 00:21:56 | 
| 合計ジャッジ時間 | 7,010 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 | 
| other | AC * 4 TLE * 1 -- * 19 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, m;
    if(!(cin >> n >> m)) return 0;
    vector<ll> a(n+1);
    for(int i = 1; i <= n; i++){
        cin >> a[i];
    }
    while(m--){
        int op;
        cin >> op;
        if(op == 1){
            int l, r;
            ll x, y;
            cin >> l >> r >> x >> y;
            for(int i = l; i <= r; i++){
                if(a[i] == x) a[i] = y;
            }
        }
        else if(op == 2){
            int l, r, k;
            cin >> l >> r >> k;
            // 收集区间 [l,r] 内出现的所有正整数
            unordered_set<ll> S;
            S.reserve(r-l+1);
            for(int i = l; i <= r; i++){
                if(a[i] > 0) S.insert(a[i]);
            }
            // 从 1 开始枚举缺失的正整数,找到第 k 个
            int cnt = 0;
            ll mex = 1;
            while(true){
                if(S.find(mex) == S.end()){
                    cnt++;
                    if(cnt == k){
                        cout << mex << "\n";
                        break;
                    }
                }
                mex++;
            }
        }
        else{
            // 不存在的操作类型,跳过输入
        }
    }
    return 0;
}
            
            
            
        