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>
using namespace std;
#define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl
#define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl
#define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl
#define eror(x) cout<<#x<<'='<<(x)<<endl
#define f_(i,a,b) for(int i=a;i>=b;i--)
#define f(i,a,b) for(int i=a;i<b;i++)
#define nb(x) __builtin_popcount(x)
#define all(v) v.begin(),v.end()
#define bit(n,k) (((n)>>(k))&1)
#define Add(x,y) x=(x+y)%mod
#define maxm(a,b) a=max(a,b)
#define minm(a,b) a=min(a,b)
#define lst(x) x[x.size()-1]
#define sz(x) int(x.size())
#define mp make_pair
#define ll long long
#define pb push_back
#define S second
#define F first
#include "rail.h"
const int N=5050;
int n,t,a[N],type[N],pos[N],dist[N][N];
/*
int getDistance(int u,int v){
cout<<"? "<<u<<" "<<v<<endl;
return dist[u][v];
}
*/
int check(int u,int v){
f(i,0,n){
if(i!=u && i!=v && dist[u][i]+dist[v][i]==dist[u][v]) return 0;
}
return dist[u][v];
}
int find(int u){
int ans=-1;
f(i,0,n){
if(i==u) continue ;
if(check(u,i) && (ans==-1 || dist[u][ans]<dist[u][i])){
ans=i;
}
}
return ans;
}
void findLocation(int _n, int first, int location[], int stype[]){
n=_n;
pos[0]=first;
f(i,0,n) f(j,i+1,n) dist[i][j]=dist[j][i]=getDistance(i,j);
int v=find(0),u=find(v);
pos[v]=pos[0]+dist[0][v],type[v]=1;
pos[u]=pos[v]-dist[u][v];
f(i,0,n){
if(i==u || i==v) continue;
if(check(i,u)) type[i]=1,pos[i]=pos[u]+dist[i][u];
else type[i]=0,pos[i]=pos[v]-dist[i][v];
}
f(i,0,n){
// cout<<type[i]<<" - "<<pos[i]<<endl;
}
f(i,0,n) location[i]=pos[i],stype[i]=type[i]+1;
}
/*
int32_t main(){
findLocation()
}*/
# | 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... |