이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |