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>
using namespace std;
const int inf=1e9;
vector<int> location, stype;
/*int getDistance(int a, int b){
cout << "getDist: " << a << " " << b << "\n" << flush;
int ans;
cin >> ans;
return ans;
}*/
void findLocation(signed n, signed first, signed location[], signed stype[]){
location[0]=first;
stype[0]=1;
if(n==1) return;
vector<int> d0(n);
int b=-1; int mini=inf;
for(int i=1; i<n; i++){
d0[i]=getDistance(0, i);
if(d0[i]<mini){
b=i;
mini=d0[i];
}
}
location[b]=first+mini;
stype[b]=2;
for(int i=1; i<n; i++){
if(i==b) continue;
int db=getDistance(b, i);
if(d0[i]<db){
location[i]=first+d0[i];
stype[i]=2;
}
else{
location[i]=first+d0[b]-db;
stype[i]=1;
}
}
}
/*signed main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
int n;
cin >> n;
int first;
cin >> first;
location.assign(n, 0);
stype.assign(n, 0);
findLocation(n, first, location, stype);
for(int i=0; i<n; i++){
cout << location[i] << " " << stype[i] << "\n";
}
}*/
# | 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... |