Codeforces Round 943 (Div 3) | Video Solutions - A to G1 | by Viraj Chandra | TLE Eliminators

  Рет қаралды 8,040

TLE Eliminators - by Priyansh

TLE Eliminators - by Priyansh

Күн бұрын

Пікірлер: 53
@TLE_Eliminators
@TLE_Eliminators 7 ай бұрын
Please fill the Feedback form for PCD: forms.gle/oMsWq1sRgMNF2oiYA
@guptafactory
@guptafactory 7 ай бұрын
Best PCD so far💥🔥🫡. He even beat Raghav sir in the clarity of explaination.
@U-DAY
@U-DAY 7 ай бұрын
Great Explanation skills man. Just keep going please don't leave in middle . I'm looking forward for every contest discussion
@mradultiwari9864
@mradultiwari9864 7 ай бұрын
you should continue @TLE_ELiminators yt channel. Your explanations are far better than ankit ghildiyal and even better than raghav goel !! please continue here
@kondekarvaishnavi2348
@kondekarvaishnavi2348 7 ай бұрын
Really cool explanation and he dicussed about tc and sc also.
@sabaokangan
@sabaokangan 6 ай бұрын
Thank you so much for sharing this with us ❤ from New York
@dandon.3667
@dandon.3667 7 ай бұрын
Great Explination
@zeno13
@zeno13 5 ай бұрын
Excellent explanation by viraj bhaiya...completely solved my doubt in problem 5
@sahil___jakhar
@sahil___jakhar 7 ай бұрын
For C my idea was similar but instead of going from the end , I started from index 0 with value 501 and then a[i] = x[i-1] + a[i-1]
@VirajChandra
@VirajChandra 7 ай бұрын
That's also a good approach!
@sparshgarg7105
@sparshgarg7105 7 ай бұрын
bro I used almost the same approach , I took a[0] = x[0] + 1 and for the rest of the elements - a[i] = x[i-1] + a[i-1] in a for loop , I tried running it in java was working fine , but it was getting accepted , can u help me why ?
@VirajChandra
@VirajChandra 7 ай бұрын
@@sparshgarg7105 If it was getting accepted then what's the issue?
@sparshgarg7105
@sparshgarg7105 7 ай бұрын
@@VirajChandra not getting accepted in Codeforces but being accepted on my IntelliJ IDE
@ujjawaltyagi8540
@ujjawaltyagi8540 7 ай бұрын
@sahil___jakhar i did with same approach but why its not getting accpeted while(t--){ int n; cin>>n; int arr[n-1]; for(int i=0;i>arr[i]; } int ans[n] = {0}; ans[0] = arr[0]+1; for(int i=1;i
@DIVYANSCKASHYAP
@DIVYANSCKASHYAP 7 ай бұрын
@TLE_Eliminators please make viraj chandra as permanent editorial video publisher for all contests and pls remove ankit ghidiyal his explanation skills are very bad
@amanandujjwalgamer9772
@amanandujjwalgamer9772 7 ай бұрын
True
@Dadgdyb
@Dadgdyb 7 ай бұрын
Be grateful for what u get
@Idk-qg7hb
@Idk-qg7hb 7 ай бұрын
@@Dadgdybidiot he is giving feedback
@Idk-qg7hb
@Idk-qg7hb 7 ай бұрын
@@Dadgdybdusre acc se ao ankit sir 😂 , btw you should actually try to improve your explanations
@Dadgdyb
@Dadgdyb 7 ай бұрын
@@Idk-qg7hb 😂😂 Ankit nahi hu bro
@filmymovies2100
@filmymovies2100 6 ай бұрын
Hello sir, i wanted to know that in the problem d, while taking all the possible outcomes of the path 5 2 7 (K=3) Why didn't we take a possiblity where bodya remains on value 5 for 2 turns and then moves to 2 at the 3rd turn i.e 5+5+2 =12?? Please explain this sir??
@VirajChandra
@VirajChandra 6 ай бұрын
We did take that, that is why we are running a loop of turns. Try to try run the code on the final loop. We are calculating prefixSum*(k-i) + currentValue, which for your case will be 5*(3-1)+2 = 12
@StudentManit-e9m
@StudentManit-e9m 6 ай бұрын
D WAS ACTUALLY hard
@sahil___jakhar
@sahil___jakhar 7 ай бұрын
For D easier idea would be one cannot repeat the element else it is the last element he/she would be taking: int n,k; cin>>n>>k; int pb,ps; cin>>pb>>ps; pb--; ps--; vi p(n); vi a(n); for(auto &x : p)cin>>x; for(auto &x : a)cin>>x; int ans_b = 0, ans_s = 0; // we have to see how much will it take to get to that particular element right int temp_sum = 0; for (int i = 0; i < n && i < k; i++) { ans_b = max(ans_b,temp_sum + a[pb]*(k-i)); temp_sum += a[pb]; pb = p[pb]-1; } temp_sum = 0; for (int i = 0; i < n && i < k; i++) { ans_s = max(ans_s,temp_sum + a[ps]*(k-i)); temp_sum += a[ps]; ps = p[ps]-1; } if(ans_b>ans_s) cout
@VirajChandra
@VirajChandra 7 ай бұрын
Great! I think this is almost the same code as explained in the solution.
@sahil___jakhar
@sahil___jakhar 7 ай бұрын
@@VirajChandra Oo sorry I didn't see your implementation part 😅
@harshavardan9054
@harshavardan9054 7 ай бұрын
My approach was a little bit different I will take the 1st number to it and add it into the array and then run the loop and multiply the number with the last index and add the same last index to get the next number of the new array but it is getting WA any idea what the issue is
@VirajChandra
@VirajChandra 7 ай бұрын
For smaller numbers this will not work!
@Sid-jb6lg
@Sid-jb6lg 7 ай бұрын
Hello Can you please tell me what's the use of hashing in question g1. Let suppose we find a some value(k) by the help of binary search now basically traverse in the string (by sliding window) and find the total number of string which of size k. Can someone tell me what's the mistake in my approach According to me it's sc is n log n(in worst case)
@VirajChandra
@VirajChandra 7 ай бұрын
I think I have replied to this comment just below.
@om-qx7wo
@om-qx7wo 7 ай бұрын
#include using namespace std; #define fastio() ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr); int main() { fastio() int t; cin >> t; while (t--) { long long n, k, PB, PS; cin >> n >> k >> PB >> PS; vector a(n); vector score(n); for (int i = 0; i < n; i++) cin >> a[i]; for (int i = 0; i < n; i++) cin >> score[i]; vector pathB; vector pathS; vector vis(n, 0); vis[PB - 1] = 1; while (true) { pathB.push_back(score[PB - 1]); PB = a[PB - 1]; if (vis[PB - 1] == 1) break; } // O(N) vis = vector(n, 0); vis[PS - 1] = 1; while (true) { pathS.push_back(score[PS - 1]); PS = a[PS - 1]; if (vis[PS - 1] == 1) break; } // O(N) long long bs = 0, ss = 0; long long preSum = 0; for (int i = 0; i < pathB.size(); i++) // O(min(pathB.size(),k)) { if (k < i + 1) break; long long currS = preSum + pathB[i] * (k - i); bs = max(bs, currS); preSum += pathB[i]; } preSum = 0; for (int i = 0; i < pathS.size(); i++) // O(min(pathS.size(),k)) { if (k < i + 1) break; long long currS = preSum + pathS[i] * (k - i); ss = max(ss, currS); preSum += pathS[i]; } if (bs > ss) cout
@VirajChandra
@VirajChandra 7 ай бұрын
Are you sure? I just submitted this code it works!
@om-qx7wo
@om-qx7wo 7 ай бұрын
@@VirajChandra yes,it worked!
@darkcarnage4608
@darkcarnage4608 7 ай бұрын
nice
@devatal3767
@devatal3767 7 ай бұрын
No sound
@guptafactory
@guptafactory 7 ай бұрын
Now corrected.
@mmmnmmmmmmmm
@mmmnmmmmmmmm 7 ай бұрын
Mistake in the title.
@TLE_Eliminators
@TLE_Eliminators 7 ай бұрын
Thanks for the correction.
@Sid-jb6lg
@Sid-jb6lg 7 ай бұрын
​@@TLE_Eliminators Hello Can you please tell me what's the use of hashing in question g1. Let suppose we find a some value(k) by the help of binary search now basically traverse in the string (by sliding window) and find the total number of string which of size k. Can someone tell me what's the mistake in my approach According to me it's sc is n log n(in worst case)
@VirajChandra
@VirajChandra 7 ай бұрын
@@Sid-jb6lg Hi! We need to find the size K strings which are same. To check their similarity, you need a hashing algo to improve TC.
@Sid-jb6lg
@Sid-jb6lg 7 ай бұрын
@@VirajChandra hey!! But both complexity same then why we are doing hashing
@VirajChandra
@VirajChandra 7 ай бұрын
@@Sid-jb6lg to compare if two strings are same you need a TC of O(N) where n is the size of the string, whereas string hashing does this is O(1) per query for (l,r) pair.
Codeforces Round 944 (Div 4) | Video Solutions - A to G | by Viraj Chandra | TLE Eliminators
2:20:22
Accompanying my daughter to practice dance is so annoying #funny #cute#comedy
00:17
Funny daughter's daily life
Рет қаралды 24 МЛН
One day.. 🙌
00:33
Celine Dept
Рет қаралды 56 МЛН
Long Nails 💅🏻 #shorts
00:50
Mr DegrEE
Рет қаралды 18 МЛН
Codeforces Round 952 (Div 4) | Video Solutions - A to H1 | by Viraj Chandra | TLE Eliminators
2:19:02
Leetcode Biweekly Contest 144 | Video Solutions - A to D | by Viraj Chandra | TLE Eliminators
1:42:08
Codeforces Round 984 (Div 3) | Video Solutions - A to G | by Abhinav Kumar | TLE Eliminators
3:12:23
Codeforces Round 954 | Video Solutions - A to E | by Abhinav Kumar | TLE Eliminators
1:58:09
TLE Eliminators - by Priyansh
Рет қаралды 7 М.
Codeforces Round 986 (Div 2) | Video Solutions - A to D | by Abhinav Kumar | TLE Eliminators
2:03:40
Leetcode Weekly Contest 424 | Video Solutions - A to D | by Viraj Chandra | TLE Eliminators
1:37:27
Errichto Stream, POI 22/1
3:55:08
Errichto Algorithms
Рет қаралды 171 М.