# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
155221 |
2019-09-27T06:59:45 Z |
KCSC |
Drzava (COCI15_drzava) |
C++14 |
|
1000 ms |
6800 KB |
#include <bits/stdc++.h>
using namespace std;
const int DIM = 50005;
const int MOD = 36691;
const int CNS = 1000000007;
const double EPS = 0.000001;
int fth[DIM], msk[DIM];
vector<int> hsh[MOD];
map<pair<int, int>, int> mmp;
struct Point {
int x, y, c;
} pts[DIM];
int _(pair<int, int> pr) {
return (1LL * pr.first % MOD * CNS + pr.second) % MOD;
}
inline int getRoot(int x) {
while (fth[x] > 0)
x = fth[x];
return x;
}
inline int sign(double x, double y) {
if (fabs(x - y) < EPS)
return 0;
return (x < y ? -1 : 1);
}
int _k;
bool unite(int x, int y, double v) {
if (sign(hypot(abs(pts[x].x - pts[y].x),
abs(pts[x].y - pts[y].y)), v * 2) > 0)
return false;
x = getRoot(x); y = getRoot(y);
if (x == y)
return false;
if (fth[x] > fth[y])
swap(x, y);
fth[x] += fth[y]; fth[y] = x;
for (int i = 0; i < _k; ++i) {
if ((msk[y] >> i) & 1) {
msk[x] |= ((1LL * msk[x]) << i) | (((1LL * msk[x]) << i) >> _k);
msk[x] &= (1 << _k) - 1;
}
}
if (msk[x] & 1)
return true;
return false;
}
bool solve(int n, int k, double v) {
mmp.clear(); v /= 2;
for (int i = 1; i <= n; ++i) {
pair<int, int> sq = make_pair(pts[i].x / v, pts[i].y / v);
if (++mmp[sq] == k)
return true;
}
for (int i = 0; i < MOD; ++i)
hsh[i].clear();
for (int i = 1; i <= n; ++i) {
fth[i] = -1;
msk[i] = (1 << pts[i].c);
}
for (int i = 1; i <= n; ++i) {
pair<int, int> sq = make_pair(pts[i].x / v, pts[i].y / v);
for (int d1 = -3; d1 <= 0; ++d1) {
for (int d2 = -3; d2 <= 3; ++d2) {
pair<int, int> nsq = make_pair(max(0, sq.first + d1),
max(0, sq.second + d2));
for (int j : hsh[_(nsq)])
if (unite(i, j, v))
return true;
}
}
hsh[_(sq)].push_back(i);
}
return false;
}
inline bool cmp(Point p1, Point p2) {
if (p1.x != p2.x)
return p1.x < p2.x;
return p1.y < p2.y;
}
int main(void) {
//freopen("drzava.in", "r", stdin);
// freopen("drzava.out", "w", stdout);
int n, k;
cin >> n >> k; _k = k;
for (int i = 1; i <= n; ++i) {
cin >> pts[i].x >> pts[i].y >> pts[i].c;
pts[i].c %= k;
}
sort(pts + 1, pts + n + 1, cmp);
double le = 0, ri = CNS * 2;
for (int i = 1; i <= 100; ++i) {
double md = (le + ri) / 2;
if (solve(n, k, md))
ri = md;
else
le = md;
}
cout << setprecision(3) << fixed << le;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1144 KB |
Output is correct |
2 |
Correct |
7 ms |
1144 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
1272 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1144 KB |
Output is correct |
2 |
Correct |
27 ms |
1552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
1272 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1144 KB |
Output is correct |
2 |
Correct |
19 ms |
1272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
1272 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1272 KB |
Output is correct |
2 |
Correct |
27 ms |
1528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1212 KB |
Output is correct |
2 |
Correct |
20 ms |
1528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
1272 KB |
Output is correct |
2 |
Execution timed out |
1051 ms |
4184 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
1148 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1144 KB |
Output is correct |
2 |
Execution timed out |
1066 ms |
6412 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
1144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1144 KB |
Output is correct |
2 |
Execution timed out |
1052 ms |
6760 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1144 KB |
Output is correct |
2 |
Execution timed out |
1067 ms |
6800 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1268 KB |
Output is correct |
2 |
Execution timed out |
1060 ms |
6668 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1120 KB |
Output is correct |
2 |
Execution timed out |
1073 ms |
6756 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1144 KB |
Output is correct |
2 |
Execution timed out |
1061 ms |
6568 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1272 KB |
Output is correct |
2 |
Execution timed out |
1064 ms |
6708 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
1144 KB |
Output is correct |
2 |
Execution timed out |
1070 ms |
6744 KB |
Time limit exceeded |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
1144 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |