void solve() { int n, h, a, b, k; cin >> n >> h >> a >> b >> k;
for(int i = 0; i < k; i++) { int t1, f1, t2, f2; cin >> t1 >> f1 >> t2 >> f2; if(t1 == t2) { cout << std::abs(f1 - f2) << endl; continue; } const auto d1 = std::abs(f1 - a) + std::abs(a - f2); const auto d2 = std::abs(f1 - b) + std::abs(b - f2); cout << std::min(d1, d2) + std::abs(t1 - t2) << endl; }
}
How can the above code fail for this problem
Auto comment: topic has been updated by ch_dktomar (previous revision, new revision, compare).
try this test case
3 is the answer I am getting.
I will travel from (f3 -> f2) -> (t1 -> t2) -> (f2 -> f3)
Seems to be a correct ans to me.
you can directly travel from tower $$$1$$$ floor $$$3$$$ to tower $$$2$$$ floor $$$3$$$, as $$$a = 2$$$ and $$$b = 4$$$
Why don't I need to go to floor 2 or 4 from floor 3 of tower 1.
well the point is to minimise the number of steps you take, so