# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
15683 |
2015-07-15T06:52:33 Z |
gs14004 |
Rail (IOI14_rail) |
C++14 |
|
0 ms |
0 KB |
#include "rail.h"
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int> pi;
int dist0[5005], distmin[5005];
bool setCheck[5005];
vector<pi> v;
void make(int location[], int stype[], int x, int st){
int last = -1;
for(auto &i : v){
if(last == -1){
stype[i.second] = x;
location[i.second] = location[st];
if(stype[i.second] == 1){
locatQion[i.second] -= i.first;
}
else{
location[i.second] += i.first;
}
last = i.second;
}
else{
int p = getDistance(i.second, last);
if(p > i.first){
stype[i.second] = x;
location[i.second] = location[st];
if(stype[i.second] == 1){
location[i.second] -= i.first;
}
else{
location[i.second] += i.first;
}
last = i.second;
}
else{
stype[i.second] = 3 - x;
location[i.second] = location[last];
if(stype[i.second] == 1){
location[i.second] -= p;
}
else{
location[i.second] += p;
}
}
}
}
}
void findLocation(int N, int first, int location[], int stype[])
{
location[0] = first;
stype[0] = 1;
int minv = 1e9, minp = -1;
for(int i=1; i<N; i++){
dist0[i] = getDistance(0,i);
if(minv > dist0[i]){
minv = dist0[i];
minp = i;
}
}
location[minp] = first + minv;
stype[minp] = 2;
for(int i=1; i<N; i++){
if(i == minp) continue;
distmin[i] = getDistance(minp, i);
if(dist0[i] == dist0[minp] + distmin[i]){
setCheck[i] = 1;
}
}
for(int i=1; i<N; i++){
if(setCheck[i]){
v.push_back(pi(distmin[i], i));
}
}
sort(v.begin(), v.end());
make(location, stype, 1, minp);
v.clear();
for(int i=1; i<N; i++){
if(i != minp && !setCheck[i]){
v.push_back(pi(dist0[i] - dist0[minp], i));
}
}
sort(v.begin(), v.end());
make(location, stype, 2, minp);
v.clear();
}
Compilation message
rail.cpp: In function 'void make(int*, int*, int, int)':
rail.cpp:18:5: error: 'locatQion' was not declared in this scope
locatQion[i.second] -= i.first;
^~~~~~~~~
rail.cpp:18:5: note: suggested alternative: 'location'
locatQion[i.second] -= i.first;
^~~~~~~~~
location