QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#481279#142. 平面最近点对james1BadCreeper#Compile Error//C++171.4kb2024-07-16 22:39:272024-07-16 22:39:27

Judging History

你现在查看的是最新测评结果

  • [2024-07-16 22:39:27]
  • 评测
  • [2024-07-16 22:39:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long i64;
const int N = 2e6 + 5; 
const i64 INF = 1e15;

int n;
struct Point {
    int x, y;
    bool operator < (const Point &a) const {
        if (x == a.x) return y < a.y;
        return x < a.x;
    }
} a[N];

inline i64 dist(int i, int j) {
    i64 x = 1ll * (a[i].x - a[j].x) * (a[i].x - a[j].x);
    i64 y = 1ll * (a[i].y - a[j].y) * (a[i].y - a[j].y);
    return x + y;
}
inline bool cmp(const int &x, const int &y) {
    return a[x].y < a[y].y;
}

int g[N];
i64 merge(int l, int r) {
    if (l == r) return INF;
    if (l + 1 == r) return dist(l, r);
    int mid = l + r >> 1;
    i64 d1 = merge(l, mid), d2 = merge(mid + 1, r);
    i64 d = min(d1, d2);
    int tot = 0;
    for (int i = l; i <= r; ++i) {
        i64 k = abs(a[mid].x - a[i].x);
        if (k < INF && k * k < d) g[++tot] = i;
    }
    sort(g + 1, g + tot + 1, cmp);
    for (int i = 1; i < tot; ++i)
        for (int j = i + 1; j <= tot && 1ll * (a[g[j]].y - a[g[i]].y) * (a[g[j]].y - a[g[i]].y) < d; ++j)
            d = min(d, dist(g[i], g[j])); 
    return d;
}

int main(void) {
    ios::sync_with_stdio(0); 
    cin >> n; 
    for (int i = 1; i <= n; ++i) cin >> a[i].x >> a[i].y; 
    sort(a + 1, a + n + 1); 
    cout << fixed << setpresision(10) << sqrt(merge(1, n)) << "\n"; 
    return 0;
}

详细

answer.code: In function ‘int main()’:
answer.code:49:22: error: ‘setpresision’ was not declared in this scope
   49 |     cout << fixed << setpresision(10) << sqrt(merge(1, n)) << "\n";
      |                      ^~~~~~~~~~~~