結果

問題 No.2220 Range Insert & Point Mex
ユーザー otamay6otamay6
提出日時 2023-02-17 22:15:18
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,634 bytes
コンパイル時間 2,207 ms
コンパイル使用メモリ 210,324 KB
実行使用メモリ 814,484 KB
最終ジャッジ日時 2023-09-26 19:30:59
合計ジャッジ時間 6,776 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 11 ms
8,444 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 255 ms
80,420 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 48 ms
24,248 KB
testcase_10 AC 50 ms
25,612 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 23 ms
15,656 KB
testcase_13 MLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int n;cin>>n;
    vector<pair<int, pair<int,int>>> op(n);
    REP(i,n){
        int l, r,a;
        cin>>l>>r>>a;
        op[i] = {a, {l, r}};
    } 
    sort(All(op));
    // 数iを含む区間[l,r]の範囲
    vector<vector<pair<int,int>>> dp(n);
    for(auto p:op){
        int a = p.first;
        pair<int,int> range = p.second;
        int l = range.first;
        int r = range.second;
        if(a >= n) {
            // どうせn以上のaは意味がない
            break;
        }
        if(a == 0) {
            dp[0].push_back(range);
        }
        else{
            for(auto prev_range: dp[a-1]){
                int nl = max(l, prev_range.first);
                int nr = min(r, prev_range.second);
                if(nl <= nr) {
                    dp[a].push_back({nl, nr});
                }
            }
        }
    }
    int q;cin>>q;
    REP(_,q){
        int x;cin>>x;
        // (l, r]の区間はSxに含まれない
        int l = -1, r = n;
        while(l+1 < r){
            int mid = (l+r) >> 1;
            bool inc = false;
            for(auto range:dp[mid]) {
                if(range.first <= x && x <= range.second) {
                    inc = true;
                    l = mid;
                    break;
                }
            }
            if(!inc) r = mid;
        }
        cout << r << "\n";
    }
}
0