提交记录 9820


用户 题目 状态 得分 用时 内存 语言 代码长度
LoliconAutomaton noi19a. 【NOI2019】回家路线 Runtime Error 85 575.397 ms 411212 KB C++ 1.62 KB
提交时间 评测时间
2019-07-16 17:14:21 2020-08-01 01:54:10
#include <bits/stdc++.h>
#define N 200010
using namespace std;
typedef long long ll;
typedef pair<int, int> pi;

template <class Int> inline void read(Int& x) {
    x = 0; char ch = getchar(); int f = 1;
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') f = -1;
    for (; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
    x *= f;
}

struct train {
    int x, y, p, q;
    bool operator<(const train& rhs) const { return (x < rhs.x) || (x == rhs.x && p < rhs.p); }
} t[N];

struct subway {
    int y, p, q;
    subway() {}
    subway(int y, int p, int q) : y(y), p(p), q(q) {}
};

struct arrival {
    int u;
    ll d, q;
    arrival() {}
    arrival(int u, ll d, ll q) : u(u), d(d), q(q) {}
};

int n, m;
ll A, B, C;
vector<subway> sub[N];
vector<arrival> f;

inline ll calc(ll x) { return A * x * x + B * x + C; }

int main() {
    read(n), read(m), read(A), read(B), read(C);
    for (int i = 1; i <= m; ++i) {
        read(t[i].x), read(t[i].y), read(t[i].p), read(t[i].q);
    }
    sort(t + 1, t + m + 1);
    for (int i = 1; i <= m; ++i) sub[t[i].x].push_back(subway(t[i].y, t[i].p, t[i].q));
    queue<arrival> q;
    q.push(arrival(1, 0, 0));
    while (!q.empty()) {
        arrival a = q.front(); q.pop();
        for (int i = 0; i < sub[a.u].size(); ++i) {
            subway tr = sub[a.u][i];
            if (a.q > tr.p) continue;
            arrival nxt(tr.y, a.d + calc(tr.p - a.q), tr.q);
            f.push_back(nxt);
            q.push(nxt);
        }
    }
    ll ret = 1e18;
    for (int i = 0; i < f.size(); ++i) {
        if (f[i].u == n) ret = min(ret, f[i].d + f[i].q);
    }
    printf("%lld\n", ret);
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1729.82 us4 MB + 644 KBAcceptedScore: 5

Testcase #2730.96 us4 MB + 644 KBAcceptedScore: 5

Testcase #3731 us4 MB + 640 KBAcceptedScore: 5

Testcase #4725.99 us4 MB + 640 KBAcceptedScore: 5

Testcase #51.236 ms4 MB + 796 KBAcceptedScore: 5

Testcase #61.254 ms4 MB + 952 KBAcceptedScore: 5

Testcase #71.269 ms5 MB + 56 KBAcceptedScore: 5

Testcase #81.259 ms5 MB + 48 KBAcceptedScore: 5

Testcase #91.243 ms4 MB + 956 KBAcceptedScore: 5

Testcase #101.116 ms4 MB + 780 KBAcceptedScore: 5

Testcase #111.161 ms4 MB + 796 KBAcceptedScore: 5

Testcase #121.297 ms4 MB + 948 KBAcceptedScore: 5

Testcase #131.252 ms4 MB + 860 KBAcceptedScore: 5

Testcase #141.683 ms5 MB + 372 KBAcceptedScore: 5

Testcase #15575.397 ms397 MB + 732 KBRuntime ErrorScore: 0

Testcase #16435.717 ms398 MB + 428 KBRuntime ErrorScore: 0

Testcase #17282.103 ms88 MB + 220 KBAcceptedScore: 5

Testcase #1827.543 ms11 MB + 456 KBAcceptedScore: 5

Testcase #19195.667 ms401 MB + 588 KBRuntime ErrorScore: 0

Testcase #2031.678 ms12 MB + 448 KBAcceptedScore: 5


Judge Duck Online | 评测鸭在线
Server Time: 2026-04-05 22:05:44 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用 | 捐赠