結果

問題 No.2220 Range Insert & Point Mex
ユーザー cho435cho435
提出日時 2023-02-17 23:00:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,615 bytes
コンパイル時間 2,325 ms
コンパイル使用メモリ 214,968 KB
実行使用メモリ 12,764 KB
最終ジャッジ日時 2023-09-26 20:22:14
合計ジャッジ時間 8,734 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,240 KB
testcase_01 AC 3 ms
7,128 KB
testcase_02 AC 4 ms
7,108 KB
testcase_03 WA -
testcase_04 AC 3 ms
7,256 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 4 ms
7,248 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 195 ms
11,348 KB
testcase_21 AC 198 ms
11,580 KB
testcase_22 AC 198 ms
11,404 KB
testcase_23 AC 154 ms
11,396 KB
testcase_24 AC 135 ms
11,264 KB
testcase_25 AC 110 ms
9,748 KB
testcase_26 AC 126 ms
11,396 KB
testcase_27 AC 90 ms
10,672 KB
testcase_28 AC 38 ms
8,072 KB
testcase_29 AC 49 ms
7,976 KB
testcase_30 AC 49 ms
8,108 KB
testcase_31 AC 127 ms
12,764 KB
testcase_32 AC 96 ms
10,656 KB
testcase_33 AC 105 ms
10,548 KB
testcase_34 AC 152 ms
11,788 KB
testcase_35 AC 160 ms
12,072 KB
testcase_36 AC 145 ms
11,808 KB
testcase_37 AC 152 ms
11,756 KB
testcase_38 AC 139 ms
12,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<int(n);i++)

int dat_sz=1<<18;
vector<ll> dat(dat_sz*2,1e18);
void SGadd(int a,int b,ll ad,int k=1,int x=0,int y=dat_sz){
  if(y<=a||b<=x) return;
  if(a<=x&&y<=b) {
    dat.at(k)=min(dat.at(k),ad);
    return;
  }
  int md=(x+y)/2;
  SGadd(a,b,ad,k*2,x,md);
  SGadd(a,b,ad,k*2+1,md,y);
}
ll SGget(int k){
  k+=dat_sz;
  ll ans=1e18;
  while(k>0){
    ans=min(ans,dat.at(k));
    k/=2;
  }
  return ans;
}


int main(){
  int n;
  cin>>n;
  vector<ll> l(n),r(n),a(n);
  rep(i,n) cin>>l.at(i)>>r.at(i)>>a.at(i);
  int q;
  cin>>q;
  vector<ll> x(q);
  rep(i,q) cin>>x.at(i);
  vector<int> nl(n),nr(n);
  rep(i,n){
    nl.at(i)=lower_bound(x.begin(),x.end(),l.at(i))-x.begin();
    nr.at(i)=upper_bound(x.begin(),x.end(),r.at(i))-x.begin();
  }
  vector<int> pr(n);
  rep(i,n) pr.at(i)=i;
  sort(pr.begin(),pr.end(),[&](int i,int j){
    return a.at(i)<a.at(j);
  });
  vector<pair<int,int>> st;
  int nw=0;
  if(a.at(pr.at(0))!=0) SGadd(0,q,0);
  for(int i:pr){
    if(nw<a.at(i)){
      sort(st.begin(),st.end());
      int str=0;
      for(auto [sl,sr]:st){
        if(str<sl) SGadd(str,sl,nw);
        str=sr;
      }
      if(str<q) SGadd(str,q,nw);
      st.clear();
      if(nw+1!=a.at(i)){
        break;
      }
      nw++;
    }
    st.emplace_back(nl.at(i),nr.at(i));
  }
  if(!st.empty()){
    sort(st.begin(),st.end());
    int str=0;
    for(auto [sl,sr]:st){
      if(str<sl) SGadd(str,sl,nw);
      str=sr;
    }
    if(str<q) SGadd(str,q,nw);
  }
  SGadd(0,q,nw+1);
  rep(i,q) cout<<SGget(i)<<'\n';
}
0