Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
98341 CSYZ_LiuF 早凉爱旅行2 C++ 运行超时 30 1000 MS 1832 KB 1142 2023-08-14 15:28:07

Tests(9/13):


#include<bits/stdc++.h> using namespace std; #ifdef IAKIOI #define cin fin ifstream cin("in.txt"); // #define cout fout // ofstream cout("out.txt"); #endif #define ll long long constexpr int N = 2e5 + 5; int x[N], y[N]; inline int abs(int x) { return x >= 0 ? x : -x; } 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) { ll t1 = min(s1 + f(i - xa, x[i] - ya), s2 + f(i - xb, x[i] - yb)) + 1; ll t2 = min(s1 + f(y[i] - xa, i - ya), s2 + f(y[i] - xb, i - yb)) + 1; s1 = t1, s2 = t2; 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; }


测评信息: