Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
98271 | CSYZ_LiuF | 早凉爱旅行2 | C++ | 运行超时 | 0 | 1000 MS | 1836 KB | 988 | 2023-08-14 13:59:09 |
#include<bits/stdc++.h> using namespace std; #ifdef IAKIOI #define cin fin ifstream cin("in.txt"); #endif #define ll long long constexpr int N = 2e5 + 5; int x[N], y[N]; inline int f(int x, int y) { return abs(x) + abs(y); } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; for (int i = 1; i < n; ++i) { cin >> x[i] >> y[i]; } while (m--) { int op, a, b, c, d; cin >> op >> a >> b >> c; if (op == 1) { x[a] = b, y[a] = c; } else { cin >> d; if (max(a, b) > max(c, d)) swap(a, c), swap(b, d); int xa = a, ya = b, xb = a, yb = b; ll s1 = 0, s2 = 0; for (int i = max(a, b); i < max(c, d); ++i) { s1 += min(f(i - xa, x[i] - ya), f(i - xb, x[i] - yb)) + 1; s2 += min(f(y[i] - xa, i - ya), f(y[i] - xb, i - yb)) + 1; xa = i + 1, ya = x[i]; xb = y[i], yb = i + 1; } cout << min(s1 + f(xa - c, ya - d), s2 + f(xb - c, yb - d)) << '\n'; } } return 0; }