Thanx for the tip! I will try to figure out a way for this.
Also here is my solution , which I think is cleaner and also slightly optimized for,
watcher:
ans=min({ans, ab1[i]+dist(a[i],b[i],c[j],d[j])+cd2[j], cd1[j]+dist(c[j],d[j],a[i],b[i])+ab2[i]});
Here, distance between the point ‘a’ and ‘b’ is calculated twice which will remain same and thus need to be calculated only once.
temp = min( ab1[i]+cd2[j], cd1[j]+ab2[i]) + dist(a[i],b[i],c[j],d[j]);
if(temp<ans) ans=temp;
Can someone check this please. I am unable to understand why am i getting WA?
https://www.codechef.com/viewsolution/28483342
ssjgz
December 25, 2019, 1:41pm
44
That’s not a link to you solution
1 Like
cfacto
December 27, 2019, 8:23am
47
Tried using Skip conditions with O(n^3) complexity but the last test case went wrong. Can this sol. be made correct with little changes ?
https://www.codechef.com/viewsolution/28510869