이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include <bits/stdc++.h>
using namespace std;
void findLocation(int N, int first, int location[], int stype[]) {
vector<bool> visited(N);
location[0] = 0;
stype[0] = 1;
visited[0] = 1;
vector<int> distancesFromZero;
for (int i=0; i<N; i++) {
if (i == 0) {
distancesFromZero.push_back(1e9); continue;
}
distancesFromZero.push_back(getDistance(0, i));
}
int nextRight = min_element(distancesFromZero.begin(), distancesFromZero.end())-distancesFromZero.begin();
stype[nextRight] = 2;
location[nextRight] = distancesFromZero[nextRight];
visited[nextRight] = 1;
vector<int> distancesFromNextRight;
for (int i=0; i<N; i++) {
if (i == nextRight) {
distancesFromNextRight.push_back(1e9); continue;
}
distancesFromNextRight.push_back(getDistance(nextRight, i));
}
// for (int i = 0; i<N; i++) {
// cerr << distancesFromZero[i] << " ";
// }
// cerr << "\n";
// for (int i = 0; i<N; i++) {
// cerr << distancesFromNextRight[i] << " ";
// }
// cerr << "\n";
// cerr << "\n";
for (int i=0; i<N; i++) {
if (visited[i]) continue;
if (distancesFromZero[nextRight] + distancesFromNextRight[i] == distancesFromZero[i]) {
stype[i] = 1;
location[i] = location[nextRight]-distancesFromNextRight[i];
visited[i] = 1;
}
if (distancesFromZero[i] + distancesFromZero[nextRight] == distancesFromNextRight[i]) {
stype[i] = 2;
location[i] = distancesFromZero[i];
visited[i] = 1;
}
}
for (int i = 0; i<N; i++) {
location[i] += first;
// cerr << location[i] << " ";
}
// cerr << "\n";
// for (int i = 0; i<N; i++) cerr << stype[i] << " ";
// cerr << "\n";
}
# | 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... |