QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#791847#142. 平面最近点对Mr_Min0 1ms3824kbC++141.1kb2024-11-28 21:20:482024-11-28 21:20:53

Judging History

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

  • [2024-11-28 21:20:53]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3824kb
  • [2024-11-28 21:20:48]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

int main() {
  cin.tie(nullptr)->sync_with_stdio(false);
  int n;
  cin >> n;
  vector < pair < int, int > > p(n);
  for (auto &[x, y] : p) cin >> x >> y;
  sort(p.begin(), p.end());
  auto sol = [&](auto &self, int l, int r) -> long double {
    if (l == r) return numeric_limits < long double > :: max();
    int m = (l + r) >> 1;
    auto d = min(self(self, l, m), self(self, m + 1, r));
    vector < pair < int, int > > q;
    auto dist = [](const auto &lhs, const auto &rhs) -> long double {
      return sqrtl(pow(lhs.first - rhs.first, 2) + pow(lhs.second - rhs.second, 2));
    };
    for (int i = l; i <= r; i++) {
      if (dist(p[i], p[m]) < d) q.push_back(p[i]);
    }
    sort(q.begin(), q.end(), [](const auto &lhs, const auto &rhs) -> bool { return lhs.second < rhs.second; });
    for (size_t i = 0; i < q.size(); i++) {
      for (size_t j = i + 1; j < q.size() && abs(q[i].second - q[j].second) < d; j++) {
        d = min(d, dist(q[i], q[j]));
      }
    }
    return d;
  };
  cout << fixed << setprecision(31) << sol(sol, 0, n - 1);
  return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 15
Accepted
time: 1ms
memory: 3800kb

input:

2933
19320 28055
2053 27470
14635 1378
27582 9822
28729 107
22351 3093
17670 379
23901 4686
27182 12261
19443 8467
24208 20283
10763 10584
25953 28380
28290 27394
19572 14769
4024 12401
23295 3267
26949 176
13416 4517
23856 15413
26260 18957
18275 24409
999 3873
28202 14686
25446 2822
24009 8949
114...

output:

2.8284271247461900975275761460637

result:

ok found '2.8284271', expected '2.8284271', error '0.0000000'

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 3824kb

input:

2912
721 22031
501 17261
11583 2570
25091 26662
7053 8645
13085 13755
15427 10176
10602 28715
16277 17856
9356 11466
5758 16745
4367 27948
15523 3209
27447 13908
24316 27667
11649 8344
9848 2897
219 21503
22524 11664
5725 1460
24127 12567
25935 14858
8457 13415
16347 12044
28163 753
28967 22202
2418...

output:

13.6014705087354433451704571744756

result:

wrong answer 1st numbers differ - expected: '8.6023253', found: '13.6014705', error = '0.5811388'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%