In problem - c Why line83 if(n%2) ans+=a[n+1]; Came after Line82 ans=max(ans-k,0LL); Test case: 3 k=1 4 4 1 In this solution it is mentioned about an odd case but unable to figure it out through what basis from that question this an odd case is generated.
Hi, Regarding Problem D, Can anyone explain why did we considered only the 'i' from query for calculating 'l' and 'r', do we not need the index which is just greater than 'j'? If so why?
yup this is how I solved it using binary search #include #include #include #include #include #include #include #include #include #define ll long long int using namespace std; int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int t=1; cin>>t; while(t--){ int n,q; cin>>n>>q; //mapm; mapm; vectorv(n+1); for(int i=1;i>v[i]; m[v[i]].push_back(i); //m[v[i][0]].push_back(i); //m[v[i][1]].push_back(i); } //vectorans while(q--){ int a,b; cin>>a>>b; int x=min(a,b); int y=max(a,b); if(v[x][0]==v[y][0] || v[x][1]==v[y][1] || v[x][0]==v[y][1] || v[x][1]==v[y][0]){ cout
Please fill the Feedback form for PCD: forms.gle/RQ7jiZvgqU8NXK1a6
Great explanation!!
🔥🔥🔥
In problem - c
Why line83 if(n%2) ans+=a[n+1];
Came after
Line82 ans=max(ans-k,0LL);
Test case:
3 k=1
4 4 1
In this solution it is mentioned about an odd case but unable to figure it out through what basis from that question this an odd case is generated.
Hi,
Regarding Problem D,
Can anyone explain why did we considered only the 'i' from query for calculating 'l' and 'r', do we not need the index which is just greater than 'j'? If so why?
Sir when will the TLE 12.0 will be launched. can u please give me the expected month of launching 12.0 plz. consider this comment🙏🙏🙏🙏
Sir can I solve D without graph concept ????????
yes
yes, it's easily solvable using binary search
@@faiqueibrahimi6359 ok
yup this is how I solved it using binary search
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define ll long long int
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t=1;
cin>>t;
while(t--){
int n,q;
cin>>n>>q;
//mapm;
mapm;
vectorv(n+1);
for(int i=1;i>v[i];
m[v[i]].push_back(i);
//m[v[i][0]].push_back(i);
//m[v[i][1]].push_back(i);
}
//vectorans
while(q--){
int a,b;
cin>>a>>b;
int x=min(a,b);
int y=max(a,b);
if(v[x][0]==v[y][0] || v[x][1]==v[y][1] || v[x][0]==v[y][1] || v[x][1]==v[y][0]){
cout