比赛 果蝇王邀请赛div2 评测结果 AAAAAWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
题目名称 雪王与果蝇王游于濠梁之上 最终得分 5
用户昵称 hsl_beat 运行时间 0.094 s
代码语言 C++ 内存使用 3.66 MiB
提交时间 2026-08-27 11:38:46
显示代码纯文本
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
    freopen("play.in", "r", stdin);
    freopen("play.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int h, w;
    cin >> h >> w;
    int a, b, c;
    cin >> a >> b >> c;
    int n;
    cin >> n;
    if (n != 2) {
        cout << "ZSY喜欢玩异环。";
        return 0;
    }
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 > x2) {
        swap(x1, x2);
    }
    if (y1 > y2) {
        swap(y1, y2);
    }
    int ans = c * (x2 - x1 + y2 - y1);
    for (int i = x1; i <= x2; i++) {
        for (int j = y1; j <= y2; j++) {
            if (i == x2) {
                ans = min(ans, c * (i - x1 + j - y1) + a * (y2 - j) + b);
            } else if (j == y2) {
                ans = min(ans, c * (i - x1 + j - y1) + a * (x2 - i) + b);
            }
        }
    }
    cout << ans;
    return 0;
}