提交记录 9853


用户 题目 状态 得分 用时 内存 语言 代码长度
water_mi noi19a. 【NOI2019】回家路线 Accepted 100 787.175 ms 36236 KB C++ 2.01 KB
提交时间 评测时间
2019-07-16 22:18:14 2020-08-01 01:57:17
#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;
	}
};

const int __ = 5e6 + 10;
struct Heap {
	node h[__]; int siz;
	bool empty() { return !siz; }
	node top() { return h[1]; }
	void pop() { std::pop_heap(h + 1, h + siz + 1); --siz; }
	void push(node x) { h[++siz] = x; std::push_heap(h + 1, h + siz + 1); } 
} 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.086 ms6 MB + 944 KBAcceptedScore: 5

Testcase #21.092 ms6 MB + 944 KBAcceptedScore: 5

Testcase #31.113 ms6 MB + 944 KBAcceptedScore: 5

Testcase #41.108 ms6 MB + 944 KBAcceptedScore: 5

Testcase #51.891 ms7 MB + 216 KBAcceptedScore: 5

Testcase #62.049 ms7 MB + 256 KBAcceptedScore: 5

Testcase #72.047 ms7 MB + 228 KBAcceptedScore: 5

Testcase #82.07 ms7 MB + 264 KBAcceptedScore: 5

Testcase #92.238 ms7 MB + 292 KBAcceptedScore: 5

Testcase #101.778 ms7 MB + 236 KBAcceptedScore: 5

Testcase #111.861 ms7 MB + 196 KBAcceptedScore: 5

Testcase #122.076 ms7 MB + 244 KBAcceptedScore: 5

Testcase #131.922 ms7 MB + 212 KBAcceptedScore: 5

Testcase #142.152 ms7 MB + 220 KBAcceptedScore: 5

Testcase #15174.913 ms19 MB + 688 KBAcceptedScore: 5

Testcase #16222.438 ms24 MB + 960 KBAcceptedScore: 5

Testcase #1798.119 ms20 MB + 964 KBAcceptedScore: 5

Testcase #1871.094 ms20 MB + 48 KBAcceptedScore: 5

Testcase #19787.175 ms35 MB + 396 KBAcceptedScore: 5

Testcase #2074.454 ms20 MB + 256 KBAcceptedScore: 5


Judge Duck Online | 评测鸭在线
Server Time: 2024-05-09 01:33:03 | Loaded in 1 ms | Server Status
个人娱乐项目,仅供学习交流使用