提交记录 9854


用户 题目 状态 得分 用时 内存 语言 代码长度
water_mi noi19a. 【NOI2019】回家路线 Time Limit Exceeded 95 1 s 83928 KB C++ 1.85 KB
提交时间 评测时间
2019-07-16 22:27:02 2020-08-01 01:57:21
#include<bits/stdc++.h>
#include<bits/extc++.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;
	}
};
__gnu_pbds::priority_queue<node, less<node>, __gnu_pbds::thin_heap_tag> 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.068 ms6 MB + 944 KBAcceptedScore: 5

Testcase #21.095 ms6 MB + 944 KBAcceptedScore: 5

Testcase #31.09 ms6 MB + 944 KBAcceptedScore: 5

Testcase #41.095 ms6 MB + 944 KBAcceptedScore: 5

Testcase #51.929 ms7 MB + 232 KBAcceptedScore: 5

Testcase #62.241 ms7 MB + 312 KBAcceptedScore: 5

Testcase #72.217 ms7 MB + 284 KBAcceptedScore: 5

Testcase #82.398 ms7 MB + 340 KBAcceptedScore: 5

Testcase #92.77 ms7 MB + 428 KBAcceptedScore: 5

Testcase #101.77 ms7 MB + 232 KBAcceptedScore: 5

Testcase #111.92 ms7 MB + 212 KBAcceptedScore: 5

Testcase #122.373 ms7 MB + 316 KBAcceptedScore: 5

Testcase #132.072 ms7 MB + 244 KBAcceptedScore: 5

Testcase #142.484 ms7 MB + 300 KBAcceptedScore: 5

Testcase #15185.483 ms21 MB + 292 KBAcceptedScore: 5

Testcase #16452.147 ms39 MB + 960 KBAcceptedScore: 5

Testcase #17138.801 ms25 MB + 976 KBAcceptedScore: 5

Testcase #1872.632 ms20 MB + 184 KBAcceptedScore: 5

Testcase #191 s81 MB + 984 KBTime Limit ExceededScore: 0

Testcase #2079 ms20 MB + 996 KBAcceptedScore: 5


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