# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1018230 | Andrey | Rail (IOI14_rail) | C++14 | 49 ms | 600 KiB |
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;
void findLocation(int n, int first, int location[], int stype[])
{
location[0] = first;
stype[0] = 1;
vector<int> dis(n);
int sm = INT_MAX,p = -1;
for(int i = 1; i < n; i++) {
dis[i] = getDistance(0,i);
if(dis[i] < sm) {
sm = dis[i];
p = i;
}
}
location[p] = first+sm;
stype[p] = 2;
vector<pair<int,int>> a(0);
vector<pair<int,int>> b(0);
for(int i = 1; i < n; i++) {
if(i != p) {
cout << getDistance(p,i) << endl;
if(getDistance(p,i) < dis[i]) {
a.push_back({dis[i],i});
}
else {
b.push_back({dis[i],i});
}
}
}
cout << a.size() << " " << b.size() << " " << p << endl;
sort(a.begin(),a.end());
sort(b.begin(),b.end());
int p1 = -1;
for(int i = 0; i < b.size(); i++) {
if(p1 == -1 || getDistance(p1,b[i].second) >= dis[b[i].second]-dis[p1]) {
location[b[i].second] = first+dis[b[i].second];
stype[b[i].second] = 2;
p1 = b[i].second;
}
else {
location[b[i].second] = first+2*dis[p1]-dis[b[i].second];
stype[b[i].second] = 1;
}
}
p1 = -1;
for(int i = 0; i < a.size(); i++) {
if(p1 == -1 || getDistance(p1,a[i].second) >= dis[a[i].second]-dis[p1]) {
location[a[i].second] = first-dis[a[i].second]+2*dis[p];
stype[a[i].second] = 1;
p1 = a[i].second;
}
else {
location[a[i].second] = first+2*dis[p]-(2*dis[p1]-dis[a[i].second]);
stype[a[i].second] = 2;
}
}
for(int i = 0; i < n; i++) {
cout << location[i] << " ";
}
cout << endl;
for(int i = 0; i < n; i++) {
cout << stype[i] << " ";
}
cout << endl;
}
Compilation message (stderr)
# | 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... |