提交记录 9852


用户 题目 状态 得分 用时 内存 语言 代码长度
water_mi noi19a. 【NOI2019】回家路线 Accepted 100 869.165 ms 52112 KB C++ 1.78 KB
提交时间 评测时间
2019-07-16 22:10:50 2020-08-01 01:57:13
#include<bits/stdc++.h>

#define LL long long
#define RG register

using namespace std;
template<class T> inline void read(T &x) {
	x = 0; RG char c = getchar(); bool f = 0;
	while (c != '-' && (c < '0' || c > '9')) c = getchar(); if (c == '-') c = getchar(), f = 1;
	while (c >= '0' && c <= '9') x = x*10+c-48, c = getchar();
	x = f ? -x : x;
	return ;
}
template<class T> inline void write(T x) {
	if (!x) {putchar(48);return ;}
	if (x < 0) x = -x, putchar('-');
	int len = -1, z[20]; while (x > 0) z[++len] = x%10, x /= 10;
	for (RG int i = len; i >= 0; i--) putchar(z[i]+48);return ;
}
const int N = 1e5 + 10;
const LL inf = 1e16;
struct node {
	int t, pos;
	LL val;
	bool operator < (const node &z) const {
		return t > z.t;
	}
};
priority_queue<node> q;
int n, m, cur[N];
LL A, B, C;
struct Pair {
	int to, p, q;
	bool operator < (const Pair &z) const {
		return p < z.p;
	}
};
vector<Pair> e[N];
map<int, LL> f[N];
void solve() {
	f[1][0] = 0;
	q.push((node) {0, 1, 0});
	LL ans = inf;
	while (!q.empty()) {
		int u = q.top().pos, t = q.top().t; LL val = q.top().val; q.pop();
		if (val != f[u][t]) continue;
		if (u == n) ans = min(ans, val + t);
		while (cur[u] < e[u].size() && e[u][cur[u]].p < t) cur[u]++;
		for (int i = cur[u]; i < e[u].size(); i++) {
			int v = e[u][i].to, T = e[u][i].q;
			LL V = val + A * (e[u][i].p - t) * (e[u][i].p - t) + B * (e[u][i].p - t) + C;
			//printf("%d %d %d %d\n", v, T, V, f[v][T]);
			if (f[v][T] > V) {
				f[v][T] = V;
				q.push((node) {T, v, V});
			}
		}
	}
	printf("%lld\n", ans);
}
int main() {
	read(n), read(m), read(A), read(B), read(C);
	for (int i = 1, x, y, p, q; i <= m; i++) {
		read(x), read(y), read(p), read(q);
		f[y][q] = inf;
		e[x].push_back((Pair) {y, p, q});
	}
	for (int i = 1; i <= n; i++) sort(e[i].begin(), e[i].end());
	solve();
	return 0;
}

CompilationN/AN/ACompile OKScore: N/A

Testcase #11.072 ms6 MB + 944 KBAcceptedScore: 5

Testcase #21.099 ms6 MB + 944 KBAcceptedScore: 5

Testcase #31.106 ms6 MB + 944 KBAcceptedScore: 5

Testcase #41.098 ms6 MB + 944 KBAcceptedScore: 5

Testcase #51.87 ms7 MB + 224 KBAcceptedScore: 5

Testcase #62 ms7 MB + 288 KBAcceptedScore: 5

Testcase #72.014 ms7 MB + 260 KBAcceptedScore: 5

Testcase #82.054 ms7 MB + 296 KBAcceptedScore: 5

Testcase #92.161 ms7 MB + 344 KBAcceptedScore: 5

Testcase #101.766 ms7 MB + 232 KBAcceptedScore: 5

Testcase #111.859 ms7 MB + 204 KBAcceptedScore: 5

Testcase #122.035 ms7 MB + 276 KBAcceptedScore: 5

Testcase #131.922 ms7 MB + 232 KBAcceptedScore: 5

Testcase #142.093 ms7 MB + 256 KBAcceptedScore: 5

Testcase #15176.132 ms20 MB + 564 KBAcceptedScore: 5

Testcase #16234.764 ms32 MB + 964 KBAcceptedScore: 5

Testcase #1799.171 ms22 MB + 712 KBAcceptedScore: 5

Testcase #1871.223 ms20 MB + 112 KBAcceptedScore: 5

Testcase #19869.165 ms50 MB + 912 KBAcceptedScore: 5

Testcase #2074.467 ms20 MB + 516 KBAcceptedScore: 5


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