This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC diagnostic warning "-std=c++11"
#include <bits/stdc++.h>
#include "rail.h"
#define pb push_back
#define f first
#define s second
#define MOD 1000000007
#define flush fflush(stdout)
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(), (x).rend()
#define pii pair<int,int>
using namespace std;
const int N=5e3+5;
int n,m,T,k;
int dist[N][N];
pii c[N];
void findLocation(int N, int first, int location[], int stype[])
{
int n=N;
stype[0]=1; location[0]=first;
for (int i=0; i<n; i++) {
dist[i][i]=0; c[i]={1e9,-1};
for (int j=i+1; j<n; j++) {
dist[i][j]=getDistance(i,j);
dist[j][i]=dist[i][j];
}
}
for (int i=0; i<n; i++) {
for (int j=0; j<n; j++) {
if (i==j) continue;
if (dist[i][j]<c[i].f) {
c[i]={dist[i][j],j};
}
}
}
int y=c[0].s; stype[y]=2; location[y]=location[0]+c[0].f;
int x=c[y].s; stype[x]=1; location[x]=location[y]-c[y].f;
// cout<<"XY "<<x<<" "<<y<<endl;
vector<int> v;
for (int i=0; i<n; i++) {
if (i==x || i==y) continue;
if (dist[y][i]<dist[x][i]) v.pb(i);
}
pii l={dist[x][y],x};
for (auto a:v) {
int b=c[a].s;
int d=c[b].s;
if (b==y || dist[d][y]<dist[b][y]) {
stype[a]=1;
if (dist[y][a]>l.f) {
l={dist[y][a],a};
}
}
}
location[l.s]=location[y]-l.f;
int L=l.s;
for (int i=0; i<n; i++) {
if (i==L) continue;
int j=c[i].s;
int o=c[j].s;
if (j==L || dist[L][o]<dist[L][j]) {
stype[i]=2;
location[i]=location[L]+dist[L][i];
}
else {
stype[i]=1;
location[i]=location[L]+dist[L][j]-dist[i][j];
}
}
// cout<<"L "<<L<<endl;
// for (int i=0; i<n; i++) {
// cout<<stype[i]<<" "<<location[i]<<endl;
// }
}
Compilation message (stderr)
rail.cpp:1:32: warning: '-std=c++11' is not an option that controls warnings [-Wpragmas]
1 | #pragma GCC diagnostic warning "-std=c++11"
| ^~~~~~~~~~~~
# | 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... |