比赛 寒假集训2 评测结果 EWEWEEEEEEEEAAAAEEEE
题目名称 回家路线 最终得分 20
用户昵称 赵飞羽 运行时间 2.122 s
代码语言 C++ 内存使用 3.51 MiB
提交时间 2026-02-25 11:10:34
显示代码纯文本
#include <bits/stdc++.h>
#define int long long
using namespace std;

const int N = 110;

int n, m, a, b, c, ans;
struct node{
	int x, y, p, q;
	bool friend operator <(node u, node v) {
		return u.x < v.x;
	}
} s[N];

signed main() {
	freopen("rout.in", "r", stdin);
	freopen("rout.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n >> m >> a >> b >> c;
	for (int i = 1; i <= m; i++) cin >> s[i].x >> s[i].y >> s[i].p >> s[i].q;
	sort(s+1, s+1+m);
	for (int i = 1; i <= m - 1; i++) ans += (a * (s[i+1].p - s[i].q) * (s[i+1].p - s[i].q) + b * (s[i+1].p - s[i].q) + c);
	ans += (a * (s[1].p) * (s[1].p) + b * (s[1].p) + c + s[m].q);
	cout << ans;
	return 0;
}