이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include <queue>
#include <vector>
#include <iostream>
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>>> pq;
for (int i = 1; i < N; i++)
{
location[i] = -1;
stype[i] = -1;
int qdist = -getDistance(0, i);
pq.emplace(qdist, make_pair(0, i));
}
while (!pq.empty())
{
auto curr = pq.top();
pq.pop();
int dist = -curr.first;
int oldnr = curr.second.first;
int newnr = curr.second.second;
if (location[newnr] != -1) continue;
int pos = location[oldnr] + dist*(stype[oldnr] == 1 ? 1 : -1);
location[newnr] = pos;
stype[newnr] = (stype[oldnr] == 1 ? 2 : 1);
for (int i = 0; i < N; i++)
{
if (location[i] != -1 || i == newnr) continue;
pq.emplace(-getDistance(newnr, i), make_pair(newnr, i));
}
}
}
| # | 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... |