Submission #252816

# Submission time Handle Problem Language Result Execution time Memory
252816 2020-07-26T10:09:34 Z kartel Drzava (COCI15_drzava) C++14
16 / 160
1000 ms 65540 KB
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#define in(x) freopen(x, "r", stdin)
#define out(x) freopen(x, "w", stdout)
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("Ofast,nso-stack-protector,unroll-loops,fast-math,-O3")
//#define F first
//#define S second
#define pb push_back
#define N +100500
#define M ll(1e9 + 7)
#define sz(x) (int)x.size()
#define re return
#define oo ll(1e9)
#define el '\n'
#define Max_A int(1e9)
//#define el endl
#define pii pair <int, int>
#define err ld(1e-6)
#define Max_S int(3e6)
#define last(x) x.back()
#define all(x) (x).begin(), (x).end()
#define arr_all(x, n) (x + 1), (x + 1 + n)
using namespace std;
//using namespace __gnu_pbds;
//typedef tree <int, null_type, less_equal <int> , rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
typedef long double ld;

ld ans = 1e18;
int x[N], y[N], k, n, i, cnt[N];
bool f[35];
vector <int> g[N];
bool mrk[N];

ld rast(int i, int j) {return (sqrt(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2)));}

void dfs(int v)
{
    if (mrk[v]) return;
    mrk[v] = 1;


    for (auto u : g[v])
    {
        if (mrk[u]) continue;

        bool F[35]{0};
        for (int i = 0; i < k; i++) F[i] = f[i];
        for (int i = 0; i < k; i++)
        {
            if (F[i])
             f[(i + cnt[u]) % k] = 1;
        }
        dfs(u);
    }
}

bool gd(ld D)
{
    for (i = 1; i <= n; i++) g[i].clear(), mrk[i] = 0;

    for (i = 1; i <= n; i++)
      for (int j = i + 1; j <= n; j++)
        if (rast(i, j) + err < D)
          g[i].pb(j), g[j].pb(i);

    for (i = 1; i <= n; i++)
    {
        if (mrk[i]) continue;

        for (int j = 0; j < k; j++) f[j] = 0;

        f[cnt[i] % k] = 1;

        dfs(i);

        if (f[0]) return 1;
    }
    return 0;
}

int main()
{
    cout.precision(3);
    cout << fixed;
    srand(time(0));
    ios_base::sync_with_stdio(0);
    iostream::sync_with_stdio(0);
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);

//    in("input.txt");
//    out("output.txt");

    cin >> n >> k;

    for (i = 1; i <= n; i++) cin >> x[i] >> y[i] >> cnt[i];

    ld l = 0;
    ld r = 1e18;
    while (l + err < r)
    {
        ld md = (l + r + err) / 2.0;

        if (gd(md))
             r = md;
        else l = md + err;
    }

    cout << l;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Incorrect 3 ms 2688 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Execution timed out 1088 ms 6272 KB Time limit exceeded
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1094 ms 2688 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 142 ms 3840 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Runtime error 154 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Runtime error 189 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Runtime error 207 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Execution timed out 1088 ms 2688 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Runtime error 208 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Runtime error 198 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -