# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
835262 | Liudas | Rail (IOI14_rail) | C++17 | 172 ms | 496 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 <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "rail.h"
#include <set>
#include <vector>
#include <numeric>
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;
void findLocation(int N, int first, int location[], int stype[])
{
int lid = 0, rid = -1;
vector<int> dist(N, 0);
for(int i = 0; i < N; i ++){
if(i == lid)continue;
int temp = getDistance(lid, i);
dist[i] = temp;
}
vector<int> order(N);
iota(order.begin(), order.end(), 0);
sort(order.begin(), order.end(), [&](int a, int b){return dist[a] < dist[b];});
int d = dist[order[1]];
rid = order[1];
lid = order[0];
stype[order[0]] = 1;
stype[order[1]] = 2;
location[order[0]] = first;
location[order[1]] = first + d;
int idx = -1;
for(int i : order){
idx ++;
if(stype[i])continue;
int md = 1e9, mid = 0;
for(int j = 0; j < idx; j ++){
int t = getDistance(order[j], i);
if(t < md){
md = t;
mid = order[j];
}
}
if(stype[mid] == 2){
stype[i] = 1;
location[i] = location[mid] - md;
}
else{
stype[i] = 2;
location[i] = location[mid] + md;
}
}
}
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... |