Тёмный

A,B,C | Codeforces Round 945 (Div. 2) Editorials | Cat, Fox and Double Maximum and the Lonely Array 

Abhinav Awasthi
Подписаться 18 тыс.
Просмотров 6 тыс.
50% 1

Опубликовано:

 

26 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 67   
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
🔥 Subscribe to coding75 Pro for Live Classes, 1:1 Mentorship Sessions: coding75.com/pro ✅ Live DSA Classes ✅ Codeforces, Codechef, Leetcode Live Discussion ✅ 1:1 Mock Interviews ✅ 1:1 Mentorship Sessions ✅ 1:1 Resume Review ✅ Live Weekly Project Building Sessions ✅ Live CS Fundamental Classes In case of any queries regarding coding75, WhatsApp us here: wa.me/message/TPN76XLWVOWDB1
@itssmfaisal
@itssmfaisal 3 месяца назад
First scenario: if(freq[i] != bits[i]) return false; Second Scenario: if(freq[i] > 0 and bits[i] == 0) return false; if(freq[i] == 0 and bits[i] > 0) return false; Both scenarios might work similar but why it is not working for this probelm??
@PradeepModak-w5h
@PradeepModak-w5h 4 месяца назад
thanks a lot abhinav sir,
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Welcome
@MDMehediHasan-kp2lz
@MDMehediHasan-kp2lz 4 месяца назад
Problem B can be solved using segment tree also.
@SamsIt-hi9gf
@SamsIt-hi9gf 4 месяца назад
can please tell me the resourse for learning the segmented tree..
@TapasviArora
@TapasviArora 4 месяца назад
Segment trees + binary search 😂
@PrashanthKumar-qb6im
@PrashanthKumar-qb6im 4 месяца назад
@@SamsIt-hi9gf watch striver video on segment tree , has has covered in detail and really good. Might feel long because its almost around 1hr
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Can you please share your code
@TapasviArora
@TapasviArora 4 месяца назад
@@AbhinavAwasthi#include #include #include #include #include #include #include #include #include #define ll int using namespace std; class SegTree{ vectorseg; public: SegTree(int n){ seg.resize(4*n+1); } void build(int ind,int low,int high,vector&a){ if(low==high){ seg[ind]=a[low]; return; } else{ int mid=(low+high)>>1; build(2*ind+1,low,mid,a); build(2*ind+2,mid+1,high,a); seg[ind]=seg[2*ind+1]|seg[2*ind+2]; } } int query(int ind,int low,int high,int l,int r){ if(r1; if(iT; while(T--){ int n; cin>>n; vectorarr(n,0); for(int i=0;i>arr[i]; } SegTree s1(n); s1.build(0,0,n-1,arr); int left = 1, right = n, ans = n; while (left
@manavaggarwal2714
@manavaggarwal2714 4 месяца назад
when we apply binary search and sets low=mid+1 than there is a possibility that the k can be smaller than mid too but are we using the fact that the if k works then true for k+1 too?
@ritabratapal8489
@ritabratapal8489 4 месяца назад
The A was very complicated
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Agree
@ravikantmahto14
@ravikantmahto14 4 месяца назад
thankyou Bhaiya For This Solution
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Thanks
@rohitkumarpilania94
@rohitkumarpilania94 4 месяца назад
Why are you NEVER able to participate in these contests, BTW good explanation
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Hey, actually nowadays I am busy with some classes Probably from next week I will participate
@bitsnation1578
@bitsnation1578 4 месяца назад
if(freq[i]!=bits[i]) return false; karke q nahi check kar sakte??? why freq[i]>0&&bits[i]==0 return false; OR freq[i]==0&&bits[i]>0 return false; why these conditions?
@SamsIt-hi9gf
@SamsIt-hi9gf 4 месяца назад
because frequecy(count) of the number at particular index does not matter , the only thing matters in or operation is the avilabilty of bit. either it is set or not
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Frequency equal is not compulsory, but frequency should be either 0 or more than 1 in both
@yummytoeat3433
@yummytoeat3433 4 месяца назад
Thanku bhaiya but To be honest you need to explain code bit more it is very confusing may be it may take some more extra time but this will help us a lot
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Sure bro, actually from last few weeks I am a little more busy, because of which making quick editorials Will improve this
@yummytoeat3433
@yummytoeat3433 4 месяца назад
@@AbhinavAwasthi thanku so much
@satyarajrana5702
@satyarajrana5702 3 месяца назад
btw its OR, not XOR
@AbhinavAwasthi
@AbhinavAwasthi 2 месяца назад
Yeah, I missed it
@prantobala8505
@prantobala8505 4 месяца назад
Supper !
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Thanks
@MelonHusk7
@MelonHusk7 4 месяца назад
Bro i'm feeling so dumb right now after seeing the solution for A. Thanks though I got the explanation of why sum/2 works, the testcase 3,4,5 gives the right answer 6 with this formula. I was stuck on the logic of this testcase for 2hrs yesterday
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Don't feel so bro, I can understand this happens sometimes
@user-yj8xv2cw5l
@user-yj8xv2cw5l 4 месяца назад
i couldnt get how lo=mid+1
@aankie
@aankie 4 месяца назад
Our savior ABHINAV👑
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Bro 🙌🏻🙌🏻
@RoniBadgujjar
@RoniBadgujjar 4 месяца назад
How 6 can be possible for Problem A for test case 3 4 5 can you please give me situation in that this can happen
@devtyagi7177
@devtyagi7177 4 месяца назад
1st plays 2 games with 3rd and 1 game with 2nd= 3 games 2nd plays 3 games with 3rd= 3 games Total 6 games
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
I think someone already explained
@RoniBadgujjar
@RoniBadgujjar 3 месяца назад
@@devtyagi7177 got it
@cse100amisha6
@cse100amisha6 4 месяца назад
Sir in Question B for(int i=0;i
@nayanpahuja1919
@nayanpahuja1919 4 месяца назад
even if the freq is 1 the bit would be set, you don't check frequencies rather than if the bit is set or not using the arrays.
@itssmfaisal
@itssmfaisal 3 месяца назад
@@nayanpahuja1919 Can you please explain it with example??
@shreyxnsh.14
@shreyxnsh.14 4 месяца назад
how tf does one get intuition for A?
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Yeah, it was actually a complex one
@garvitjain240
@garvitjain240 4 месяца назад
NOT XOR ,OR
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Sorry, by mistake
@Now_I_am_all_fired_up
@Now_I_am_all_fired_up 4 месяца назад
Bhaiya B ki kya rating hogi
@kumkumslab5811
@kumkumslab5811 4 месяца назад
1100 because TLE-eliminator cp sheet ki 1100 rating me aise enough questions hai practice ke liye
@SamsIt-hi9gf
@SamsIt-hi9gf 4 месяца назад
@@kumkumslab5811 kuch bhi nearly 1300 rating hogi B ki
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Pupil to specialist maanlo
@kumkumslab5811
@kumkumslab5811 4 месяца назад
@@SamsIt-hi9gf bhai maine solve kar lia tha newbie hu ye lo approach bool areArraysEqual( vll &arr1,vll &arr2) { if (arr1.size() != arr2.size()) { return false; } for (ll i = 0; i < arr1.size(); ++i) { if ((arr1[i] >=1 && arr2[i]=1 && arr1[i] 2*n) return false; vll temp(63,0); for (ll i = 0; i < mid && i < n; i++) { ll xr = arr[i]; for(int i=0;i>i)&1==1){ temp[i]++; } } } ll i=mid; ll j=0; vll temp2=temp; while(ik)&1==1){ temp2[k]--; } } ll newEle=arr[i]; for(int k=0;k>k)&1==1){ temp2[k]++; } } bool ans=areArraysEqual(temp,temp2); if(ans==0)return 0; i++; } return true; } void solve(){ ll n; cin>>n; vectorarr(n); for(ll i=0;i>arr[i]; } if(n==1){ cout
@kumkumslab5811
@kumkumslab5811 4 месяца назад
Building an Aquarium ye questions try kro
@TanmayKhandelwal-z9v
@TanmayKhandelwal-z9v 4 месяца назад
Sir..why the second problem is solved using binary search...please explain
@ayushjaiswal2020
@ayushjaiswal2020 4 месяца назад
if there is answer for window size k, the condition is also true for k+1 window size.
@TanmayKhandelwal-z9v
@TanmayKhandelwal-z9v 4 месяца назад
@@ayushjaiswal2020 how??
@SamsIt-hi9gf
@SamsIt-hi9gf 4 месяца назад
@@TanmayKhandelwal-z9v because every smaller segement reside inside the large segment. just use pen try to draw by own. it will be clear.
@aisharawat9102
@aisharawat9102 4 месяца назад
@@ayushjaiswal2020 Yes please how you got the logic that it will be true for k+1 and further. I dry run it and found it to be true. But like how ??
@ayushjaiswal2020
@ayushjaiswal2020 4 месяца назад
@@aisharawat9102 1) If there is something to find min/max in problem, try to think if binary search can happen. 2) So to check if search space is monotonic, I evaluated for k+1 window size.
@eshanchourasia287
@eshanchourasia287 4 месяца назад
#include using namespace std ; int check(int k , vectora){ vectorv(22,0) ; for(int i = 0 ; i0){ if(x%2){ v[j]++ ; } j++ ; x=x/2 ; } } int i=k ; vectorfrq; frq=v ; while(i0){ if(x%2){ frq[j]++ ; } j++ ; x = x/2 ; } x= a[i-k] ; j= 0 ; while(x>0){ if(x%2==0){ frq[j]-- ; } j++ ; x = x/2 ; } for(int f = 0 ; f0){ return -1 ; } if(frq[f]>0 && v[f]==0){ return -1 ; } } i++ ; } return 1 ; } int main(){ int t ; cin>>t ; while(t>0){ t-- ; int n ; cin>>n ; vectora ; for(int i = 0 ;i>element ; a.push_back(element) ; } int low =1 ; int high = a.size(); int ans = 0 ; while(low
@AbhinavAwasthi
@AbhinavAwasthi 4 месяца назад
Hey, can you please dry run?
@eshanchourasia287
@eshanchourasia287 4 месяца назад
@@AbhinavAwasthi i have solved it 👍
@piyushraj5464
@piyushraj5464 3 месяца назад
Thanks for such clear solutions. Please make video solutions for all the upcoming contests.
@mayankparmar4321
@mayankparmar4321 4 месяца назад
#include using namespace std; int main(){ int t; cin>>t; while(t--){ int n; cin>>n; int em=0; int om=0; int a[n]; int ans=0; priority_queue e,o; for(int i=0;i>a[i]; if(i&1) { o.push(a[i]); om+=a[i]; } else{ e.push(a[i]); em+=a[i]; } if(a[i]==n) ans=i; } map m; int x=(n/2)+1; if(em>om ||((em==om) && ans%2==0)){ while(!e.empty()){ m[e.top()]=x; x++; e.pop(); } x=1; while(!o.empty()){ m[o.top()]=x; x++; o.pop(); } } else { while(!o.empty()){ m[o.top()]=x; x++; o.pop(); } x=1; while(!e.empty()){ m[e.top()]=x; x++; e.pop(); } } for(int i=0;i
Далее
Help Me Celebrate! 😍🙏
00:35
Просмотров 13 млн
Kenji's Sushi Shop Showdown - Brawl Stars Animation
01:55
LeetCode was HARD until I Learned these 15 Patterns
13:00
Google Coding Interview With A High School Student
57:24
I Asked LinkedIn Software Engineers How To Get Hired
10:49
How I Passed The Google Coding Interviews
18:50
Просмотров 47 тыс.