# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1021611 | MarwenElarbi | Rail (IOI14_rail) | C++17 | 46 ms | 1104 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 <bits/stdc++.h>
#include "rail.h"
using namespace std;
#define ll long long
#define fi first
#define se second
#define pb push_back
void findLocation(int N, int first, int location[], int stype[])
{
vector<pair<int,int>> a;
map<int,int> mp;
mp[first]=0;
location[0]=first;
stype[0]=1;
for (int i = 1; i < N; ++i)
{
a.pb({getDistance(0,i),i});
}
sort(a.begin(),a.end());
mp[a[0].fi+first]=a[0].se;
location[a[0].se]=a[0].fi+first;
stype[a[0].se]=2;
int l,r;
l=0;
r=a[0].se;
for (int i = 1; i < a.size(); ++i)
{
int cura=getDistance(l,a[i].se);
int curb=getDistance(r,a[i].se);
int m=(cura-curb+location[l]+location[r])/2;
int test=(mp.find(m)==mp.end()?(m>first ? 1 : 2):stype[mp[m]]);
if(test^2){
stype[a[i].se]=2;
location[a[i].se]=location[l]+cura;
if(location[a[i].se]>location[r])
r=a[i].se;
}else{
stype[a[i].se]=1;
location[a[i].se]=location[r]-curb;
if(location[a[i].se]<location[l])
l=a[i].se;
}
mp[location[a[i].se]]=a[i].se;
}
return;
}
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... |