D. Rain
| |
| |
| |
| |
| |
| |
| |
| |
| #include <bits/stdc++.h> |
| using namespace std; |
| #define int long long |
| const int M=1e6+5; |
| const int inf=1e15; |
| |
| struct node { |
| int pos,k; |
| bool operator<(const node T)const { |
| if(pos!=T.pos)return pos<T.pos; |
| return k<T.k; |
| } |
| }; |
| |
| int n,m; |
| int x[M],p[M],d[M],mx,mn; |
| void up(int id,int v) { |
| if(v<=m)return ; |
| mx=max(mx,id+v-m); |
| mn=min(mn,id-v+m); |
| } |
| |
| |
| signed main() { |
| int TT;cin>>TT; |
| while(TT--) { |
| vector<node>v; |
| cin>>n>>m; |
| mx=-inf,mn=inf; |
| v.push_back({-inf,0}); |
| v.push_back({inf,0}); |
| for(int i=1;i<=n;i++) { |
| cin>>x[i]>>p[i]; |
| v.push_back({x[i]-p[i]+1,1}); |
| v.push_back({x[i]+1,-2}); |
| v.push_back({x[i]+p[i]+1,1}); |
| } |
| sort(v.begin(),v.end()); |
| int pre=0; |
| for(int i=1;i<v.size()-1;i++) { |
| d[i]=d[i-1]+v[i].k; |
| if(v[i].pos!=v[i+1].pos) { |
| up(v[i].pos,pre+d[i]); |
| up(v[i+1].pos-1,pre+d[i]*(v[i+1].pos-v[i].pos)); |
| } |
| pre+=d[i]*(v[i+1].pos-v[i].pos); |
| } |
| for(int i=1;i<=n;i++) { |
| if((x[i]+p[i])>=mx&&(x[i]-p[i])<=mn)cout<<"1"; |
| else cout<<"0"; |
| } |
| cout<<'\n'; |
| } |
| return 0; |
| } |
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 地球OL攻略 —— 某应届生求职总结
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· 提示词工程——AI应用必不可少的技术
· .NET周刊【3月第1期 2025-03-02】