# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1206836 | _callmelucian | Circus (Balkan15_CIRCUS) | C++17 | 4091 ms | 4424 KiB |
#include <bits/stdc++.h>
#include "circus.h"
using namespace std;
using ll = long long;
using ld = long double;
using pl = pair<ll,ll>;
using pii = pair<int,int>;
using tpl = tuple<int,int,int>;
#define all(a) a.begin(), a.end()
#define filter(a) a.erase(unique(all(a)), a.end())
int dist[2020][2020], p[2020], n, m;
bool vis[2020][2020];
void dfs (int i, int pre) {
if (vis[i][pre]) return;
vis[i][pre] = 1;
for (int nxt = 0; nxt < n; nxt++)
if (!vis[nxt][i] && abs(p[nxt] - p[i]) >= abs(p[i] - p[pre])) dfs(nxt, i);
}
void init (int N, int M, int P[]) {
/// input processing
for (int i = 0; i < N; i++) p[i] = P[i];
p[N] = M, n = N + 1, m = M;
sort(p, p + n);
dfs(N, N);
}
int minLength (int D) {
int ans = INT_MAX;
for (int i = 0; i < n; i++)
for (int j = 0; j < n; j++)
if (vis[i][j] && abs(D - p[i]) >= abs(p[i] - p[j])) ans = min(ans, abs(D - p[i]));
return ans;
}
#ifdef LOCAL
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int N = 3, M = 8;
int P[3] = {0, 3, 6};
init(N, M, P);
cout << minLength(4) << " " << minLength(5) << "\n";
return 0;
}
#endif // LOCAL
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |