QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#93008#142. 平面最近点对Joyslog#0 1ms5764kbC++141.5kb2023-03-31 09:47:272023-03-31 09:47:31

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-31 09:47:31]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:5764kb
  • [2023-03-31 09:47:27]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAX_N = 4e5 + 10;
const double INF = 1e20;
int n;
double ans = INF;
pii p[MAX_N];
inline bool cmpx(pii x, pii y) {return x.first < y.first;}
inline bool cmpy(pii x, pii y) {return x.second < y.second;}

inline ll read() {
    ll ret = 0, w = 1; char c = getchar();
    while(!isdigit(c))    {if(c == '-')    w = -1; c = getchar();}
    while(isdigit(c))    {ret = (ret << 1) + (ret << 3) + (c ^ 48); c = getchar();}
    return ret * w;
}

double dis(pii x, pii y) {
    double dx = 1.0 * x.first - y.first, dy = 1.0 * x.second - y.second;
    return sqrt(dx * dx + dy * dy);
}
void solve(int l, int r) {
    if(l + 1 >= r)  return;
    int mid = (l + r) >> 1, midx = p[mid].first;
    solve(l, mid), solve(mid, r);
    inplace_merge(p + l, p + mid, p + r, cmpy);
    vector<int> t;
    for(int i = l; i < r; i++)
        if((double)abs((double)midx - p[i].first) <= ans)    t.push_back(i);
    int i = 0, j = 0;
    for(; i < (int)t.size(); i++) {
        while(j < (int)t.size() && (double)p[t[j]].second <= (double)p[t[i]].second + ans)
            j++;
        for(int k = i + 1; k < j; k++)
            ans = min(ans, dis(p[t[i]], p[t[k]]));
    }
}

int main() {
    n = read();
    for(int i = 0; i < n; i++)
        p[i].first = read(), p[i].second = read();
    sort(p, p + n, cmpx);
    solve(0, n);
    cout << ans << endl;
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

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

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.82843

result:

wrong answer 1st numbers differ - expected: '2.8284271', found: '2.8284300', error = '0.0000010'

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%