# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
7543 |
2014-08-10T14:55:16 Z |
baneling100 |
Rail (IOI14_rail) |
C++ |
|
148 ms |
2232 KB |
#include "rail.h"
#include <algorithm>
#include <vector>
using namespace std;
pair <int,int> A[5000];
vector <int> Up;
vector <int> Down;
int Check[5000];
void findLocation(int N, int First, int location[], int stype[])
{
int i, j, k, Left, Right, Dist, OK;
location[0]=First;
stype[0]=1;
for(i=1 ; i<N ; i++)
A[i]=make_pair(getDistance(0,i),i);
sort(A,A+N);
location[A[1].second]=location[0]+A[1].first;
stype[A[1].second]=2;
for(i=2 ; i<N ; i++)
{
Dist=getDistance(A[1].second,A[i].second);
if(A[i].first==A[1].first+Dist && location[A[1].second]-Dist<location[0])
Check[A[i].second]=Dist;
}
Right=A[1].second;
Up.push_back(A[1].second);
for(i=2 ; i<N ; i++)
if(!Check[A[i].second])
{
OK=1;
Dist=getDistance(Right,A[i].second);
k=Up.size();
for(j=0 ; j<k && OK ; j++)
{
if(A[i].first==(location[Up[j]]-location[0])+(Dist-(location[Right]-location[Up[j]])))
{
location[A[i].second]=location[Right]-Dist;
stype[A[i].second]=1;
OK=0;
}
}
if(OK)
{
location[A[i].second]=location[0]+A[i].first;
stype[A[i].second]=2;
Right=A[i].second;
Up.push_back(A[i].second);
}
}
Left=0;
Down.push_back(0);
for(i=2 ; i<N ; i++)
if(Check[A[i].second])
{
OK=1;
Dist=getDistance(Left,A[i].second);
k=Down.size();
for(j=0 ; j<k && OK ; j++)
{
if(Check[A[i].second]==(location[A[1].second]-location[Down[j]])+(Dist-(location[Down[j]]-location[Left])))
{
location[A[i].second]=location[Left]+Dist;
stype[A[i].second]=2;
OK=0;
}
}
if(OK)
{
location[A[i].second]=location[A[1].second]-Check[A[i].second];
stype[A[i].second]=1;
Left=A[i].second;
Down.push_back(A[i].second);
}
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
360 KB |
Output is correct |
3 |
Correct |
2 ms |
360 KB |
Output is correct |
4 |
Correct |
2 ms |
396 KB |
Output is correct |
5 |
Correct |
2 ms |
444 KB |
Output is correct |
6 |
Correct |
2 ms |
492 KB |
Output is correct |
7 |
Correct |
2 ms |
492 KB |
Output is correct |
8 |
Correct |
2 ms |
492 KB |
Output is correct |
9 |
Correct |
2 ms |
624 KB |
Output is correct |
10 |
Correct |
2 ms |
624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
624 KB |
Output is correct |
2 |
Correct |
2 ms |
624 KB |
Output is correct |
3 |
Correct |
2 ms |
624 KB |
Output is correct |
4 |
Correct |
2 ms |
624 KB |
Output is correct |
5 |
Correct |
2 ms |
624 KB |
Output is correct |
6 |
Correct |
2 ms |
624 KB |
Output is correct |
7 |
Correct |
2 ms |
624 KB |
Output is correct |
8 |
Correct |
2 ms |
624 KB |
Output is correct |
9 |
Correct |
3 ms |
624 KB |
Output is correct |
10 |
Correct |
3 ms |
624 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
700 KB |
Output is correct |
2 |
Correct |
107 ms |
748 KB |
Output is correct |
3 |
Correct |
99 ms |
844 KB |
Output is correct |
4 |
Correct |
106 ms |
916 KB |
Output is correct |
5 |
Correct |
99 ms |
980 KB |
Output is correct |
6 |
Correct |
112 ms |
1024 KB |
Output is correct |
7 |
Correct |
98 ms |
1064 KB |
Output is correct |
8 |
Correct |
96 ms |
1112 KB |
Output is correct |
9 |
Correct |
106 ms |
1152 KB |
Output is correct |
10 |
Correct |
97 ms |
1224 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
102 ms |
1336 KB |
Output is correct |
2 |
Correct |
97 ms |
1336 KB |
Output is correct |
3 |
Correct |
101 ms |
1336 KB |
Output is correct |
4 |
Correct |
94 ms |
1376 KB |
Output is correct |
5 |
Correct |
104 ms |
1420 KB |
Output is correct |
6 |
Correct |
95 ms |
1600 KB |
Output is correct |
7 |
Correct |
100 ms |
1600 KB |
Output is correct |
8 |
Correct |
98 ms |
1600 KB |
Output is correct |
9 |
Correct |
119 ms |
1672 KB |
Output is correct |
10 |
Correct |
98 ms |
1700 KB |
Output is correct |
11 |
Correct |
97 ms |
1700 KB |
Output is correct |
12 |
Correct |
148 ms |
1740 KB |
Output is correct |
13 |
Correct |
97 ms |
1788 KB |
Output is correct |
14 |
Correct |
99 ms |
1952 KB |
Output is correct |
15 |
Correct |
125 ms |
1952 KB |
Output is correct |
16 |
Correct |
113 ms |
1952 KB |
Output is correct |
17 |
Correct |
92 ms |
1964 KB |
Output is correct |
18 |
Correct |
102 ms |
2000 KB |
Output is correct |
19 |
Correct |
92 ms |
2132 KB |
Output is correct |
20 |
Correct |
111 ms |
2232 KB |
Output is correct |