이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "rail.h"
#define gd getDistance
#define eb emplace_back
using namespace std;
void findLocation(int N, int first, int L[], int T[]) {
T[0]=1;
L[0]=0;
vector<int> D(N), S;
int mn=(1e9), mi;
for (int i=1; i<N; i++) {
D[i]=gd(0, i);
if (mn>D[i]) mn=D[i], mi=i;
}
T[mi]=2;
L[mi]=mn;
int l=0, r=mi;
for (int i=0; i<N; i++) if (i!=l&&i!=r) S.eb(i);
sort(S.begin(), S.end(), [&](int x, int y) { return D[x]<D[y]; });
for (auto &i:S) {
int d1=gd(l, i), d2=gd(r, i);
if (d1==d2+L[r]-L[l]) {
L[i]=L[r]-d2;
T[i]=1;
if (L[i]<L[l]) l=i;
}
else if (d1+L[r]-L[l]==d2) {
L[i]=L[l]+d1;
T[i]=2;
if (L[i]>L[r]) i=r;
}
else assert(false);
}
for (int i=0; i<N; i++) L[i]=L[i]+first;
}
컴파일 시 표준 에러 (stderr) 메시지
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:18:4: warning: 'mi' may be used uninitialized in this function [-Wmaybe-uninitialized]
18 | T[mi]=2;
| ^~
# | 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... |