Help required for wrong output.

Revision en2, by ch_dktomar, 2024-08-09 09:26:11

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

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English ch_dktomar 2024-08-09 09:26:11 46
en1 English ch_dktomar 2024-08-09 09:25:30 646 Initial revision (published)