# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
252808 |
2020-07-26T09:58:11 Z |
VEGAnn |
Drzava (COCI15_drzava) |
C++14 |
|
148 ms |
11980 KB |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define PB push_back
using namespace std;
using namespace __gnu_pbds;
typedef long double ld;
typedef long long ll;
const int N = 5010;
const int md = 998244353;
const int PW = 233;
const ld E = 1e-9;
const int K = 33;
ll dist[N][N];
int n, x[N], y[N], vl[N], pr[N], k;
bool mrk[N], ff[K], f[K];
ll sqr(ll x) { return (x * x); }
int get(int x) { return (pr[x] == x ? x : pr[x] = get(pr[x])); }
bool ok(ll len){
for (int i = 0; i < n; i++)
pr[i] = i;
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++)
if (dist[i][j] <= len){
pr[get(j)] = get(i);
}
fill(mrk, mrk + n, 0);
for (int i = 0; i < n; i++){
int cr = get(i);
if (mrk[cr]) continue;
mrk[cr] = 1;
fill(f, f + K, 0);
for (int j = i; j < n; j++){
if (get(j) != cr) continue;
fill(ff, ff + K, 0);
ff[vl[j]] = 1;
for (int it = 0; it < k; it++)
if (f[it])
ff[(it + vl[j]) % k] = 1;
for (int it = 0; it < k; it++)
f[it] |= ff[it];
}
if (f[0]) return 1;
}
return 0;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n >> k;
assert(n < N);
for (int i = 0; i < n; i++){
cin >> x[i] >> y[i] >> vl[i];
vl[i] %= k;
}
for (int i = 0; i < n; i++)
for (int j = i + 1; j < n; j++){
dist[i][j] = dist[j][i] = sqr(x[i] - x[j]) + sqr(y[i] - y[j]);
}
ll l = 1, r = ll(1e18);
while (l < r){
ll md = (l + r) >> 1;
if (ok(md))
r = md;
else l = md + 1;
}
cout << fixed << setprecision(3) << sqrt(ld(l));
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
118 ms |
9856 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
115 ms |
9724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
54 ms |
5120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
113 ms |
9472 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Correct |
148 ms |
11980 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
34 ms |
4480 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
9 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Runtime error |
8 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Runtime error |
9 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
9 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Runtime error |
10 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Runtime error |
14 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
9 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
9 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
512 KB |
Output is correct |
2 |
Runtime error |
9 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Runtime error |
13 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
9 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Runtime error |
9 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |