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

ch_dktomar's blog

By ch_dktomar, history, 7 weeks ago, In English

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

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it