QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#508118 | #5588. Eroding Pillars | stasio6 | WA | 60ms | 13652kb | C++14 | 2.0kb | 2024-08-07 03:45:04 | 2024-08-07 03:45:04 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define PB push_back
#define FS first
#define SD second
#define ary(k) array<int,k>
template<class A,class B> void cmx(A& x, B y) {x=max<A>(x,y);}
template<class A,class B> void cmn(A& x, B y) {x=min<A>(x,y);}
typedef pair<int, int> pii;
typedef vector<int> vi;
int x[1002], y[1002];
vector<vi> kra;
int low[1002], gl[1002], ok;
void dfs(int n, int o) {
gl[n] = gl[o] + 1;
low[n] = gl[n];
for (auto v : kra[n]) {
if (v == o)
continue;
if (low[v]) {
cmn(low[n], low[v]);
continue;
}
dfs(v, n);
cmn(low[n], low[v]);
if (n != 0 && low[v] >= gl[n])
ok = 0;
}
// cerr << n << " " << low[n] << " " << gl[n] << "\n";
}
bool check (int n, int d) {
// cerr << d << "\n";
ok = 1;
kra.clear();
kra.resize(n+1);
for (int i = 0; i <= n; i++) {
low[i] = gl[i] = 0;
for (int j = i + 1; j <= n; j++) {
if ((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]) <= d)
kra[i].PB(j), kra[j].PB(i);
}
}
dfs(0, 0);
// cerr << ok << "ok\n";
return ok;
}
signed main() {
cin.tie(0)->sync_with_stdio(0); cin.exceptions(cin.failbit);
int n;
cin >> n;
for (int i = 1; i <= n; i++) {
cin >> x[i] >> y[i];
}
vector<int> dists;
for (int i = 0; i <= n; i++) {
for (int j = i + 1; j <= n; j++) {
dists.PB((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
}
}
sort(all(dists));
int pocz = 0, kon = sz(dists) - 1;
while (pocz < kon) {
int sr = (pocz + kon) / 2;
if (check(n, dists[sr])) {
kon = sr;
} else {
pocz = sr + 1;
}
}
cout << fixed << setprecision(10) << sqrt(dists[pocz]) << "\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3892kb
input:
2 1 1 1 0
output:
1.4142135624
result:
ok found '1.4142136', expected '1.4142136', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3792kb
input:
8 1 1 0 1 1 0 2 0 0 2 2 1 1 2 2 2
output:
1.0000000000
result:
ok found '1.0000000', expected '1.0000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 3864kb
input:
1 1000000000 -1000000000
output:
1414213562.3730950356
result:
ok found '1414213562.3730950', expected '1414213562.3730950', error '0.0000000'
Test #4:
score: -100
Wrong Answer
time: 60ms
memory: 13652kb
input:
1000 -197140284 703496508 105426106 -447628446 -321789030 -547969163 -275840107 -183856400 977079157 55081681 562400795 -99876434 -833457368 849631307 427777786 981882 -477648368 423363280 -986742316 -207582454 546089414 986224147 648775399 760817052 -111756907 833096696 -702954343 -487408110 -20831...
output:
124439312.6837210506
result:
wrong answer 1st numbers differ - expected: '129014631.0649485', found: '124439312.6837211', error = '0.0354636'