提交记录 10675


用户 题目 状态 得分 用时 内存 语言 代码长度
Mikanbouya noi19a. 【NOI2019】回家路线 Runtime Error 70 196.862 ms 395736 KB C++11 1.58 KB
提交时间 评测时间
2019-09-24 21:26:39 2020-08-01 02:19:00
#include <cstdio>
#include <cctype>
#include <cstring>
#include <algorithm>
#define il inline
#define rgi register int
#define sp putchar(' ')
#define el putchar('\n')
using namespace std;
il int ri() {
    register int o1 = 0;
    register bool o2 = 0;
    register char o3;
    while (!isdigit(o3 = getchar())) o2 |= o3 == '-';
    while (isdigit(o3)) o1 = (o1 << 1) + (o1 << 3) + (o3 ^ 48), o3 = getchar();
    return o2 ? -o1 : o1;
}
il void wi(int o1) {
    if (o1 < 0)
        putchar('-'), o1 = -o1;
    rgi o2 = o1 / 10;
    if (o2)
        wi(o2);
    putchar((o1 - (o2 << 1) - (o2 << 3)) ^ 48);
}
const int maxn = 1e5 + 5;
const int maxm = 2e5 + 5;
const int maxt = 1e3 + 5;
const int inf = 0x3f3f3f3f;
int n, m, a, b, c, t, f[maxn][maxt], ans = inf;
struct edge {
    int u, v, p, q;
} e[maxm];
il int calc(int x) { return a * x * x + b * x + c; }
il bool cmp(edge o1, edge o2) { return o1.p <= o2.p; }
signed main() {
    //freopen("route.in", "r", stdin);
    //freopen("route.out", "w", stdout);
    n = ri(), m = ri(), a = ri(), b = ri(), c = ri();
    for (rgi i = 1; i <= m; ++i) {
        e[i].u = ri(), e[i].v = ri(), e[i].p = ri(), e[i].q = ri();
        t = max(t, e[i].q);
    }
    memset(f, 0x3f, sizeof(f));
    f[1][0] = 0;
    sort(e + 1, e + m + 1, cmp);
    for (rgi i = 1; i <= m; ++i)
        for (rgi j = 0; j <= e[i].p; ++j) {
            if (f[e[i].u][j] == inf)  //没车
                continue;
            f[e[i].v][e[i].q] = min(f[e[i].v][e[i].q], f[e[i].u][j] + calc(e[i].p - j));
        }
    for (rgi i = 0; i <= t; ++i) ans = min(ans, f[n][i] + i);
    wi(ans);
    return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #132.172 ms383 MB + 424 KBAcceptedScore: 5

Testcase #232.183 ms383 MB + 424 KBAcceptedScore: 5

Testcase #332.156 ms383 MB + 424 KBAcceptedScore: 5

Testcase #432.204 ms383 MB + 424 KBAcceptedScore: 5

Testcase #533.578 ms383 MB + 484 KBAcceptedScore: 5

Testcase #633.636 ms383 MB + 484 KBAcceptedScore: 5

Testcase #733.586 ms383 MB + 484 KBAcceptedScore: 5

Testcase #833.609 ms383 MB + 484 KBAcceptedScore: 5

Testcase #933.56 ms383 MB + 484 KBAcceptedScore: 5

Testcase #1033.455 ms383 MB + 484 KBAcceptedScore: 5

Testcase #1161.202 ms386 MB + 468 KBRuntime ErrorScore: 0

Testcase #12111.817 ms386 MB + 468 KBRuntime ErrorScore: 0

Testcase #1357.282 ms386 MB + 468 KBRuntime ErrorScore: 0

Testcase #1433.636 ms383 MB + 484 KBAcceptedScore: 5

Testcase #15189.104 ms386 MB + 468 KBRuntime ErrorScore: 0

Testcase #16192.387 ms386 MB + 468 KBRuntime ErrorScore: 0

Testcase #17182.889 ms386 MB + 472 KBAcceptedScore: 5

Testcase #18185.288 ms386 MB + 468 KBRuntime ErrorScore: 0

Testcase #19196.862 ms386 MB + 472 KBAcceptedScore: 5

Testcase #20187.43 ms386 MB + 472 KBAcceptedScore: 5


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