提交记录 9827


用户 题目 状态 得分 用时 内存 语言 代码长度
LoliconAutomaton noi19a. 【NOI2019】回家路线 Time Limit Exceeded 85 1 s 576272 KB C++ 1.61 KB
提交时间 评测时间
2019-07-16 17:20:21 2020-08-01 01:54:57
#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);
            if (tr.y == n) f.push_back(nxt);
            q.push(nxt);
        }
    }
    ll ret = 1e18;
    for (int i = 0; i < f.size(); ++i) {
        ret = min(ret, f[i].d + f[i].q);
    }
    printf("%lld\n", ret);
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #1788.62 us4 MB + 636 KBAcceptedScore: 5

Testcase #2793.41 us4 MB + 636 KBAcceptedScore: 5

Testcase #3796.27 us4 MB + 636 KBAcceptedScore: 5

Testcase #4774.37 us4 MB + 636 KBAcceptedScore: 5

Testcase #51.279 ms4 MB + 780 KBAcceptedScore: 5

Testcase #61.299 ms4 MB + 844 KBAcceptedScore: 5

Testcase #71.317 ms4 MB + 808 KBAcceptedScore: 5

Testcase #81.293 ms4 MB + 832 KBAcceptedScore: 5

Testcase #91.286 ms4 MB + 824 KBAcceptedScore: 5

Testcase #101.167 ms4 MB + 780 KBAcceptedScore: 5

Testcase #111.227 ms4 MB + 780 KBAcceptedScore: 5

Testcase #121.342 ms4 MB + 812 KBAcceptedScore: 5

Testcase #131.317 ms4 MB + 784 KBAcceptedScore: 5

Testcase #141.631 ms4 MB + 900 KBAcceptedScore: 5

Testcase #151 s218 MB + 360 KBTime Limit ExceededScore: 0

Testcase #161 s306 MB + 876 KBTime Limit ExceededScore: 0

Testcase #17231.014 ms26 MB + 736 KBAcceptedScore: 5

Testcase #1827.714 ms11 MB + 356 KBAcceptedScore: 5

Testcase #19333.49 ms562 MB + 784 KBRuntime ErrorScore: 0

Testcase #2031.186 ms11 MB + 508 KBAcceptedScore: 5


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