Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
98157 | CSYZYeShuChen | 早凉爱旅行2 | C++ | 解答错误 | 0 | 133 MS | 3408 KB | 1367 | 2023-08-14 12:24:03 |
#include<bits/stdc++.h> using namespace std; const int N = 2e5 + 5; int n, m; int x[N], y[N]; int vis1[N], vis2[N]; int lx[N], rx[N], ly[N], ry[N]; int main() { ios::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin >> n >> m; for(int i = 1; i < n; i++) { cin >> x[i] >> y[i]; vis1[i] = x[i]; vis2[i] = y[i]; } for(int i = 1; i <= m; i++) { int op, a, b, c, d; cin >> op; if(op == 1) { cin >> a >> b >> c; x[a] = b; y[a] = c; vis1[a] = x[a]; vis2[a] = y[a]; } if(op == 2) { int mx1 = 0, mx2 = 0; cin >> a >> b >> c >> d; mx1 = max(a, b); mx2 = max(c, d); int ans = abs(mx1 - mx2); if(mx1 == a) { int dis1 = abs(b - vis2[a]), dis2 = abs(a - b) + a - vis1[a]; if(mx2 == c) { dis1 += abs(d - vis2[a]); dis2 += abs(c - vis1[a]) + c - d; } else { dis1 += abs(d - vis2[a]) + d - c; dis2 += abs(c - vis1[a]); } ans = ans + min(dis1, dis2); } else { int dis1 = abs(a - vis1[b]), dis2 = abs(a - b) + b - vis2[b]; if(mx2 == d) { dis1 += abs(c - vis1[b]); dis2 += abs(d - vis2[b]) + d - c; } else { dis1 += abs(c - vis1[b]) + c - d; dis2 += abs(d - vis2[b]); } ans = ans + min(dis1, dis2); } cout << ans << '\n'; } } return 0; }