Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Help required for wrong output.

Правка en2, от 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

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en2 Английский ch_dktomar 2024-08-09 09:26:11 46
en1 Английский ch_dktomar 2024-08-09 09:25:30 646 Initial revision (published)