I could not understand the term and significance in this Cf round 676 - D

what is the meaning of delta and delta_a and delta_b in the solution ??

code : image

Problem : https://codeforces.com/contest/1421/problem/D

hey @aryan_007 if you know that above we have declared an array dx and dy with some points .
so when in the code at that current point we do so thar we can completely fill with these directions in the matrix or can perform computations so at that particular step we are storing values in those variables .

So, why we are using this and what it means in visual terms like slope or something like that ??

have you gine through the editorial of the code ?

yes, but i could not understand this and no the reason as it only says that we can move in 2 directions and it will do the job, but how are we moving with the help of this code, i could not understand that !!

just want to know what that delta means??

if the point is 4,4 at any current point then suppose the cordinates are -1,1 in dx and dy then dint yuo think when you will do 4+(-1) ,4+1 you will move at different block in the matrix.
like the resutant if this is :
3,5 .

sir, i think we can not move from 4,4 to 3,5 . See, the figure in that can you go from 1,1 to 0,2

It is the video editorial, it is made by the author of this contest, i could not understand this as well

i have just given the example above how you can move .
in the code which you have mentioned above there are dx and dy and cordinated will be icremented according to that in code ;

Okay sir, but what it actually mean ?? ( i mean it is basically dx[i]/dy[i] - dx[j]/dy[j] , what it means can you please clear this

they are doing this to find the shortest path from (0,0) to desired point in the hexagon .
Happy Learning !!

areyyyyyy sir ye to muje bhi pata hai but kese ??? Aap baat ko ghuma kyo rahe ho ??

hello @aryan_007
i dont know what he is trying in that code.
check this ->
seedha seedha kiya hua hai .

image


void solve() {
	ll x, y; cin >> x >> y;
	ll c1, c2, c3, c4, c5, c6;
	cin >> c1 >> c2 >> c3 >> c4 >> c5 >> c6;
	ll n1, n2, n3, n4, n5, n6; 
	n1 = min(c1,c2+c6);
	n2 = min(c2,c1+c3);
	n3 = min(c3,c2+c4);
	n4 = min(c4,c3+c5);
	n5 = min(c5,c4+c6);
	n6 = min(c6,c1+c5);
	ll ans=0;
	if(x>=0&&y>=0) {
		ll d= min(x,y);
		ans+=d*n1;
		x-=d;
		y-=d;
		if(x>0)ans+=n6*x;
		if(y>0)ans+=n2*y;
	} else if(x<=0&&y>=0) {
		x=-x;
		ans+=y*n2;
		ans+=x*n3;
	} else if(x<=0&&y<=0) {
		x=-x;y=-y;
		ll d=min(x,y);
		ans+=d*n4;
		x-=d;
		y-=d;
		if(x>0)ans+=x*n3;
		if(y>0)ans+=y*n5;
	} else if(x>=0&&y<=0){
		y=-y;
		ans+=x*n6;
		ans+=y*n5;
	}
	cout << ans << "\n";
}
1 Like

Areyyy sir, legendry sir, legendry, what a seamless easy to read code, you have written !!! Orz sir, a big Orz, thank you sir !!!

no bro its not mine solution, i took it from codeforces.

kaafi easy solution tha isiliye share kar diya

1 Like

Fir bhi sir, Thank you sir !! ( Editorial was very hard to understand ) but this was very easy to understand !!