# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
252925 |
2020-07-26T13:20:25 Z |
islingr |
Drzava (COCI15_drzava) |
C++14 |
|
864 ms |
4660 KB |
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define trav(x, v) for (auto &x : v)
#define lb(x...) lower_bound(x)
#define x first
#define y second
const int N = 1 << 16, K = 1 << 6;
const ll inf = 2e8;
int nxt[N];
int head(int u) { return nxt[u] != u ? nxt[u] = head(nxt[u]) : u; }
void unite(int u, int v) { nxt[head(u)] = head(v); }
using pii = pair<int, int>;
ll norm(const pii &p, const pii &q) {
return (ll) (p.x - q.x) * (p.x - q.x) + (ll) (p.y - q.y) * (p.y - q.y);
}
pair<pii, short> tmp[N];
pii p(int i) { return tmp[i].x; }
int n; short k;
vector<short> cmp[N];
bool f(ll d) {
rep(u, 0, n) nxt[u] = u, cmp[u].clear();
int r = floor(sqrt(d)), l = 0;
set<pair<int, int>> S;
rep(i, 0, n) {
while (p(i).x - p(l).x > r) S.erase({p(l).y, l}), ++l;
int cnt = 0;
for (auto it = S.lb({p(i).y - r, -1});
it != end(S) && it->x - r <= p(i).y; ++it) {
if (norm(p(it->y), p(i)) <= d) unite(it->y, i);
if (8 * k <= ++cnt) return true;
}
S.insert({p(i).y, i});
}
rep(u, 0, n) cmp[head(u)].push_back(tmp[u].y);
rep(z, 0, n) {
if (cmp[z].empty()) continue;
if (size_t(k) <= cmp[z].size()) return true;
ll S = 0;
trav(v, cmp[z]) {
S |= (S | 1) << v;
S |= S >> k;
S &= (1ll << k) - 1;
if (S & 1) return true;
}
}
return false;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> k;
rep(i, 0, n) {
int x, y, c; cin >> x >> y >> c;
tmp[i] = {{x, y}, c % k};
}
sort(tmp, tmp + n);
ll l = 0, r = inf * inf;
while (r - l > 1) {
ll m = l + (r - l + 1) / 2;
(f(m) ? r : l) = m;
}
cout << fixed << setprecision(3) << sqrt(r);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
2 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
2 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
22 ms |
1964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
9 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
30 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
24 ms |
1956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
19 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
12 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
143 ms |
3064 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
864 ms |
4464 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
669 ms |
4472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
554 ms |
4336 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
624 ms |
4660 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
633 ms |
4600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
295 ms |
4472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
360 ms |
4600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
407 ms |
4592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
396 ms |
4528 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
337 ms |
4612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
320 ms |
4600 KB |
Output is correct |