# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
252960 |
2020-07-26T14:34:53 Z |
islingr |
Drzava (COCI15_drzava) |
C++14 |
|
338 ms |
10892 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 eb(x...) emplace_back(x)
#define lb(x...) lower_bound(x)
#define x first
#define y second
const int N = 1 << 16, K = 1 << 6;
const ll inf = 2e8;
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; }
bool vis[N]; vector<int> g[N]; vector<short> cmp;
void unite(int u, int v) { g[u].eb(v); g[v].eb(u); }
void dfs(int u) {
vis[u] = 1; cmp.eb(tmp[u].y);
for (int v : g[u]) if (!vis[v]) dfs(v);
}
int n; short k;
bool f(ll d) {
int r = floor(sqrt(d)), l = 0;
set<pair<int, int>> S;
rep(u, 0, n) g[u].clear(), vis[u] = 0;
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 (k <= ++cnt) return 1;
}
}
S.insert({p(i).y, i});
}
rep(u, 0, n) {
if (vis[u]) continue;
cmp.clear(); dfs(u);
if (size_t(k) <= cmp.size()) return 1;
ll S = 0;
for (auto v : cmp) {
S |= (S | 1) << v;
S |= S >> k;
S &= (1ll << k) - 1;
if (S & 1) return 1;
}
}
return 0;
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0);
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 |
1 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 |
5 ms |
2048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
4 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
5 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
5 ms |
2048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
5 ms |
2048 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
4 ms |
1920 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
68 ms |
3104 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
330 ms |
10892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
338 ms |
10616 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
265 ms |
8188 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
277 ms |
8440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1920 KB |
Output is correct |
2 |
Correct |
276 ms |
8568 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
187 ms |
4892 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
219 ms |
5752 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
216 ms |
7192 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
205 ms |
7236 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
213 ms |
5240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
1920 KB |
Output is correct |
2 |
Correct |
201 ms |
5368 KB |
Output is correct |