A - New Building for SIS
题意:英语阅读,ab之间都有通道。
#include<bits/stdc++.h> using namespace std; typedef long long ll; void test_case() { int n, h, a, b, q; scanf("%d%d%d%d%d", &n, &h, &a, &b, &q); while(q--) { int t1, h1, t2, h2; scanf("%d%d%d%d", &t1, &h1, &t2, &h2); if(t1 == t2) printf("%d\n", abs(h1 - h2)); else if(a <= h1 && h1 <= b || a <= h2 && h2 <= b) printf("%d\n", abs(h1 - h2) + abs(t1 - t2)); else printf("%d\n", min(abs(h1 - a) + abs(h2 - a), abs(h1 - b) + abs(h2 - b)) + abs(t1 - t2)); } } int main() { #ifdef KisekiPurin freopen("KisekiPurin.in", "r", stdin); #endif // KisekiPurin int t = 1; for(int ti = 1; ti <= t; ++ti) { //printf("Case #%d: ", ti); test_case(); } }