This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "rail.h"
/// #pragma GCC optimize ("Ofast")
/// #pragma GCC target ("avx2")
/// #pragma GCC optimize("unroll-loops")
using namespace std;
using ll = long long;
using ld = long double;
#define ff first
#define ss second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb lower_bound
const int MOD = 998244353;
int DP[5005][5005];
int query(int i, int j) {
if(i == j) return 0;
if(DP[i][j] != -1)
return DP[i][j];
return DP[i][j] = getDistance(i, j);
}
void findLocation(int n, int first, int location[], int stype[]) {
location[0] = first;
stype[0] = 1; int D = -1;
memset(DP, -1, sizeof DP);
for(int l = 1; l < n; l++) {
if(D == -1 || query(0, l) < query(0, D)) D = l;
}
stype[D] = 2; location[D] = first + query(0, D);
for(int l = 1; l < n; l++) {
if(l == D) continue;
int A = query(0, l), B = query(D, l), C = query(0, D);
if(B + C == A) stype[l] = 1, location[l] = first - A + 2 * B;
else stype[l] = 2, location[l] = first + A;
}
}
# | 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... |