結果
| 問題 |
No.814 ジジ抜き
|
| コンテスト | |
| ユーザー |
beet
|
| 提出日時 | 2019-04-12 22:53:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 2,884 bytes |
| コンパイル時間 | 2,554 ms |
| コンパイル使用メモリ | 212,472 KB |
| 最終ジャッジ日時 | 2025-01-07 01:59:04 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 MLE * 1 |
| other | WA * 1 TLE * 16 MLE * 6 |
ソースコード
#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()){
if(l!=r) sp.emplace(l,r);
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);
assert(p.first<=l0*2&&p.second<=r0*2);
assert(p.first<=l1*2+1&&p.second<=r1*2+1);
assert(p.first>l0*2-2&&p.second>r0*2-2);
assert(p.first>l1*2-1&&p.second>r1*2-1);
//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);
}
Int cnt=0;
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;
cnt++;
}
// assert(cnt==1);
return 0;
}
beet