楼上的大佬怎么都写的这么长啊(蒟蒻的恐惧),其实仔细一看,就是枚举吗

思路

先用一个pair去存储坐标,放在数组a中,然后通过遍历不断去寻找最大的一个并且更新,最后输出即可

#include <bits/stdc++.h>
using namespace std;
#define sc second
#define fr first
#define int long long
int n, m, num, cnt = 0, l = 1, r = 1e10;
string s;
void solve()
{
    cin >> n;
    vector<pair<int, int>> a(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i].first >> a[i].second;//输入数据
    }
    int mx = -1;
    int x1, y1, x2, y2;

    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)//双层for,时间复杂度O(n2)不会超的
        {
            int dx = a[i].first - a[j].first;//多加几个变量,看着会很清晰哦
            int dy = a[i].second - a[j].second;
            int dist = dx * dx + dy * dy;//算距离的平方有两点好处,一是不用再写sqrt了,二是可以避免精度丢失的情况
            if (dist > mx)//如果找到了更大的,就更新
            {
                mx = dist;
                x1 = a[i].first;
                y1 = a[i].second;
                x2 = a[j].first;
                y2 = a[j].second;
            }
        }
    }

    cout << x1 << " " << y1 << " " << x2 << " " << y2 << endl;
}

signed main()
{
    ios::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int awa = 1;
    // cin >> awa;
    while (awa--)//niehiahia喜欢的话别忘了点个赞再走哦awa
    {
        solve();
    }
    return 0;
}