Please read the new rule regarding the restriction on the use of AI tools. ×

Help required for understanding the code and where is gone wrongwrong output.
Difference between en1 and en2, changed 46 character(s)
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](https://codeforces.net/problemset/problem/1020/A)

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)