We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
cant understand what to do after this its not able to pass test cases other than test case0
#include<cmath>#include<string.h>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>usingnamespacestd;classNode{public:intdata;intpos;Node*next;};intmain(){/* Enter your code here. Read input from STDIN. Print output to STDOUT */Node*start=newNode();start=NULL;intQ;cin>>Q;charop;intpos,pos1,pos2,plus,M;while(Q--){Node*n=newNode();cin>>op;if(op=='U')//Update{intsum=0;cin>>pos>>M>>plus;intN=1000000;//1 millionfor(inti=1;i<=50;i++){intback=pos;for(intj=1;j<=1000;j++){Node*p=newNode();p->data=M;p->pos=pos-1;p->next=NULL;if(start==NULL){start=p;n=p;}else{n->next=p;n=p;}ints,in=__builtin_popcount(pos);for(intk=0;;k++){s=pos+pow(2,k);if(__builtin_popcount(s)<=in){in=__builtin_popcount(s);pos=s;if(pos>N)break;Node*p=newNode();p->data=M;p->pos=pos-1;p->next=NULL;n->next=p;n=p;}}pos=pos-N;}pos=back+plus;if(pos>N)pos-=N;}}else{cin>>pos1>>pos2;longlongx=0;Node*p=newNode();p=start;while(p->next!=NULL){if(p->pos>pos1&&p->pos<pos2)x+=p->data;p=p->next;}cout<<x<<endl;}}return0;}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Jaggu Playing with Balloons
You are viewing a single comment's thread. Return to all comments →
cant understand what to do after this its not able to pass test cases other than test case0