답안 #252820

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
252820 2020-07-26T10:14:25 Z kartel Drzava (COCI15_drzava) C++14
32 / 160
364 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;

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

ll rast(int i, int j) {return (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(ll 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) <= 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];

    ll l = 0;
    ll r = 2e18;
    while (l < r)
    {
        ll md = (l + r) / 2;

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

    cout << sqrt(l);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Correct 2 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Incorrect 2 ms 2688 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 250 ms 6272 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 364 ms 6860 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Correct 88 ms 3872 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Runtime error 156 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2688 KB Output is correct
2 Runtime error 193 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 2560 KB Output is correct
2 Runtime error 175 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Runtime error 183 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Runtime error 176 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2688 KB Output is correct
2 Runtime error 179 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2688 KB Output isn't correct
2 Halted 0 ms 0 KB -