AcWing
  • 首页
  • 活动
  • 题库
  • 竞赛
  • 商店
  • 应用
  • 文章
    • 题解
    • 分享
    • 问答
  • 吐槽
  • 登录/注册

AcWing 1671. 三角形 0.01 AC币

作者: 作者的头像   Liyb ,  2022-08-04 18:08:12 ,  所有人可见 ,  阅读 3


0


//枚举一个点,找和它横坐标相等的最大点和纵坐标相等的最大点
//在所有方案中取最优解
#include <iostream>
#include <cstring>
#include <algorithm>

using namespace std;
const int N = 110;
typedef pair<int, int> PII;

#define x first
#define y second

PII q[N];
int main()
{
    int n;cin >> n;
    for(int i = 0; i < n; i ++)
    {
        int x,y;cin >> x >> y;
        q[i] = {x, y};
    }

    int res = 0;
    for(int i = 0; i < n; i ++)
    {
        int a = 0,b = 0;
        for(int j = 0; j < n; j ++)
        {
            if(q[i].x == q[j].x)a = max(a, abs(q[j].y - q[i].y));
            if(q[i].y == q[j].y)b = max(b, abs(q[j].x - q[i].x));
        }

        res = max(res, a * b);
    }

    printf("%d\n",res);
    return 0;
}

0 评论

你确定删除吗?

© 2018-2022 AcWing 版权所有  |  京ICP备17053197号-1
用户协议  |  常见问题  |  联系我们
AcWing
请输入登录信息
更多登录方式: 微信图标 qq图标
请输入绑定的邮箱地址
请输入注册信息