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 <rail.h>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define F first
#define FOR(i,a,b) for (auto i = (a); i <= (b); ++i)
#define NFOR(i,a,b) for(auto i = (a); i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) lli(x.size())
#define mp(i,a) make_pair(i,a)
#define pb(a) push_back(a)
#define bit(x,b) (x&(1LL<<b))
typedef long long int lli;
typedef pair <lli,lli> ii;
typedef pair <ii,lli> iii;
typedef pair <ii,ii> iiii;
typedef vector <lli> vi;
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
void findLocation(int n, int first, int location[], int stype[])
{
int dis[n],mi=-1,in=1;
location[0]=first;
stype[0]=1;
for(int i=1;i<n;++i)
{
dis[i]=getDistance(0,i);
if(i==1)
{
mi=dis[i];
in=i;
}
else if(dis[i]<mi)
{
mi=dis[i];
in=i;
}
}
location[in]=first+mi;
stype[in]=2;
for(int i=1;i<n;++i)
{
if(i==in)
continue;
int d=getDistance(in,i),d1;
if(dis[in]+d==dis[i])
{
d1=getDistance(i,in);
if(d1==d)
{
location[i]=mi-d1;
stype[i]=2;
}
else
{
location[i]=mi-d1;
stype[i]=1;
}
}
else
{
d1=getDistance(i,0);
if(d1==dis[i])
{
location[i]=first+d1;
stype[i]=1;
}
else
{
location[i]=first+d1;
stype[i]=2;
}
}
}
}
# | 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... |