diff --git a/2751. Robot Collisions b/2751. Robot Collisions new file mode 100644 index 0000000..fecf9d7 --- /dev/null +++ b/2751. Robot Collisions @@ -0,0 +1,64 @@ +class Solution { +public: +void segmentUpdate(int l,int le,int re,vector>&h){ + int i=le,j=le+1; + while(i>=l&&j<=re){ + if(h[i].second==0){i--;continue;} + if(h[j].second==0){j++;continue;} + if(h[i].second > h[j].second){ + h[i].second--;h[j++].second=0; + }else if(h[i].second < h[j].second){ + h[j].second--;h[i--].second=0; + }else{ + h[i].second=0;i--; + h[j].second=0;j++; + } + } +} +void update(vector>&h,vector>&d){ + int i=0; + while(i>&h,vector>&d){ + int right=d.size(),left=-1; + for(int i=0;i survivedRobotsHealths(vector& po, vector& he, string di) { + vector>h; + vector>d; + for(int i=0;ires(po.size()); + unordered_mappos; + for(int i=0;i ans; + for(auto f:res)if(f)ans.push_back(f); + return ans; + } +};