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 <bits/stdc++.h>
using namespace std;
void findLocation(int n, int first, int location[], int stype[]) {
location[0]=first;
stype[0]=1;
priority_queue<pair<int,pair<int,int>>,vector<pair<int,pair<int,int>>>,greater<pair<int,pair<int,int>>>> q;
vector<bool> seen(n,0);
seen[0]=1;
vector<int> md(n,2000000);
for(int i=1; i<n; i++) if(!seen[i]){
int d=getDistance(0,i);
if(d<md[i]){
md[i]=d;
q.emplace(d, make_pair(i,0));
}
}
while(!q.empty()){
auto t=q.top();
auto p=t.second;
q.pop();
if(seen[t.second.first]) continue;
seen[t.second.first]=1;
stype[p.first]=stype[p.second]==1?2:1;
location[p.first]=location[p.second]+t.first*(stype[p.second]==1?1:-1);
for(int i=1; i<n; i++) if(!seen[i]){
int d=getDistance(p.first,i);
if(d<md[i]){
md[i]=d;
q.emplace(d, make_pair(i,p.first));
}
}
}
}
# | 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... |