# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
409408 |
2021-05-20T16:36:41 Z |
MDario |
Rail (IOI14_rail) |
C++11 |
|
91 ms |
964 KB |
#include "rail.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
void findLocation(int N, int first, int location[], int stype[]){
for(int i=0; i<N; i++){
stype[i]=0;
}
location[0]=first;
stype[0]=1;
if(N==1)return;
int a[N];
a[0]=0;
map<ll, ll> m;
vector<pair<ll, ll>> v, v1;
for(int i=1; i<N; i++){
a[i]=getDistance(0, i);
v.push_back({a[i], i});
}
sort(v.begin(), v.end());
int l=0, r=v[0].S, dl=0, dr=0, c=0;
location[r]=first+v[0].F;
stype[r]=2;
m[location[l]]=1;
m[location[r]]=2;
for(int i=1; i<N-1; i++){
dl=getDistance(l, v[i].S);
dr=getDistance(r, v[i].S);
c=(location[l]+dl+location[r]-dr)/2;
if(m[c]==0){
if(c>first){
stype[v[i].S]=2;
location[v[i].S]=location[l]+dl;
if(location[v[i].S]>location[r])r=v[i].S;
}
else{
stype[v[i].S]=1;
location[v[i].S]=location[r]-dr;
if(location[v[i].S]<location[l])l=v[i].S;
}
}
else if(m[c]==1){
stype[v[i].S]=2;
location[v[i].S]=location[l]+dl;
if(location[v[i].S]>location[r])r=v[i].S;
}
else{
stype[v[i].S]=1;
location[v[i].S]=location[r]-dr;
if(location[v[i].S]<location[l])l=v[i].S;
}
m[location[v[i].S]]=stype[v[i].S];
}
return ;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
376 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
376 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
372 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
91 ms |
964 KB |
Output is correct |
2 |
Correct |
85 ms |
868 KB |
Output is correct |
3 |
Correct |
85 ms |
892 KB |
Output is correct |
4 |
Correct |
90 ms |
888 KB |
Output is correct |
5 |
Correct |
90 ms |
876 KB |
Output is correct |
6 |
Correct |
86 ms |
892 KB |
Output is correct |
7 |
Correct |
88 ms |
888 KB |
Output is correct |
8 |
Correct |
86 ms |
840 KB |
Output is correct |
9 |
Correct |
88 ms |
876 KB |
Output is correct |
10 |
Correct |
88 ms |
876 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
85 ms |
880 KB |
Output is correct |
2 |
Correct |
89 ms |
872 KB |
Output is correct |
3 |
Correct |
85 ms |
964 KB |
Output is correct |
4 |
Correct |
88 ms |
892 KB |
Output is correct |
5 |
Correct |
86 ms |
836 KB |
Output is correct |
6 |
Correct |
86 ms |
888 KB |
Output is correct |
7 |
Correct |
86 ms |
888 KB |
Output is correct |
8 |
Correct |
86 ms |
876 KB |
Output is correct |
9 |
Correct |
90 ms |
876 KB |
Output is correct |
10 |
Correct |
88 ms |
876 KB |
Output is correct |
11 |
Correct |
85 ms |
880 KB |
Output is correct |
12 |
Correct |
87 ms |
872 KB |
Output is correct |
13 |
Correct |
87 ms |
840 KB |
Output is correct |
14 |
Correct |
87 ms |
876 KB |
Output is correct |
15 |
Correct |
88 ms |
884 KB |
Output is correct |
16 |
Correct |
88 ms |
888 KB |
Output is correct |
17 |
Correct |
86 ms |
832 KB |
Output is correct |
18 |
Correct |
89 ms |
888 KB |
Output is correct |
19 |
Correct |
86 ms |
908 KB |
Output is correct |
20 |
Correct |
87 ms |
872 KB |
Output is correct |