답안 #252805

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
252805 2020-07-26T09:57:02 Z VEGAnn Drzava (COCI15_drzava) C++14
64 / 160
150 ms 8312 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 = 1010;
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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 512 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 114 ms 7288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 105 ms 7168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 49 ms 4736 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 112 ms 7160 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Correct 150 ms 8312 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 35 ms 4480 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 512 KB Output is correct
2 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 1 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 384 KB Output is correct
2 Runtime error 2 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)