結果

問題 No.814 ジジ抜き
ユーザー beetbeet
提出日時 2019-04-12 22:38:55
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,631 bytes
コンパイル時間 3,681 ms
コンパイル使用メモリ 216,484 KB
実行使用メモリ 55,308 KB
最終ジャッジ日時 2023-10-12 22:15:44
合計ジャッジ時間 36,308 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,352 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
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 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct FastIO{
  FastIO(){
    cin.tie(0);
    ios::sync_with_stdio(0);
  }
}fastio_beet;

struct DS{
  using P = pair<Int, Int>;
  set<P> sp;
  // [l, r)
  void add(Int l,Int r){
    assert(l!=r);
    if(sp.empty()){
      sp.emplace(l,r);
      return;
    }
    while(1){
      auto it=sp.upper_bound(P(l,l));
      if(it==sp.begin()) break;        
      it--;        
      Int pl,pr;
      tie(pl,pr)=*it;
      assert(pl<l);
        
      if(pr<=l) break;
      if(r<=pr){
        sp.erase(P(pl,pr));
        if(pl!=l) sp.emplace(pl,l);
        if(r!=pr) sp.emplace(r,pr);
        return;
      }
        
      if(pl!=l) sp.emplace(pl,l);
      l=pr;
      break;
    }
      
    while(l<r){
      auto it=sp.upper_bound(P(l,l));
      if(it==sp.end()) break;
      Int nl,nr;
      tie(nl,nr)=*it;
      assert(l<=nl);
      if(r<=nl){
        if(l!=r) sp.emplace(l,r);
        break;
      }
      if(r<=nr){
        sp.erase(P(nl,nr));
        if(l!=nl) sp.emplace(l,nl);
        if(r!=nr) sp.emplace(r,nr);
        return;
      }
        
      assert(nr<r);
      sp.erase(P(nl,nr));
      if(l!=nl) sp.emplace(l,nl);
      l=nr;
    }
  }
};

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> a(n),b(n),c(n);
  for(Int i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];


  vector<Int> l(n),r(n),v(n),w(n);
  for(Int i=0;i<n;i++){
    w[i]=1LL<<c[i];
    v[i]=b[i]%w[i];
    l[i]=b[i]/w[i];
    r[i]=l[i]+a[i];
    // cout<<v[i]<<" "<<w[i]<<" "<<l[i]<<" "<<r[i]<<endl;
  }


  map<Int, DS> dp;
  for(Int t=0;t<60;t++){
    for(Int i=0;i<n;i++){
      if(c[i]!=t) continue;
      dp[v[i]].add(l[i],r[i]);
    }    
    map<Int, DS> nx;
    for(auto &st:dp){
      Int x=st.first;
      for(auto p:st.second.sp){
        // cout<<t<<" "<<x<<":"<<p.first<<" "<<p.second<<endl;
        Int n0=x;
        Int n1=x|(1LL<<t);

        Int l0=(p.first+1)>>1;
        Int l1=l0-(p.first&1);
        
        Int r0=(p.second+1)>>1;
        Int r1=r0-(p.second&1);

        //cout<<p.first<<" "<<p.second;
        //cout<<":"<<l0<<" "<<r0<<":"<<l1<<" "<<r1<<endl;
        if(l0!=r0) nx[n0].add(l0,r0);
        if(l1!=r1) nx[n1].add(l1,r1);        
      }
    }
    swap(dp,nx);
  }
  
  for(auto &p:dp){
    if(p.second.sp.empty()) continue;
    auto it=p.second.sp.begin();
    assert((it->first)+1==(it->second));
    Int x=p.first+(1LL<<60)*(it->first);
    cout<<x<<endl;
  }
  return 0;
}
0