이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "rail.h"
#include <bits/stdc++.h>
#define xx first
#define yy second
using namespace std;
long long int typedef li;
int dist[5003][5003];
int d(int i, int j)
{
if (i>j) swap(i,j);
if (!dist[i][j]) dist[i][j]=getDistance(i,j);
return dist[i][j];
}
map<int,int> zauz;
void findLocation(int n, int first, int location[], int stype[])
{
location[0]=first,stype[0]=1,zauz[first]=1;
vector<pair<int,int>> ok;
for (int i=1;i<n;i++) ok.push_back({d(0,i),i});
sort(ok.begin(),ok.end());
int L=0,R=ok.front().yy;
location[R]=location[L]+d(L,R),stype[R]=2,zauz[location[R]]=stype[R];
bool skip=true;
for (auto [di,k] : ok)
{
if (skip)
{
skip=false;
continue;
}
if (zauz[location[L]+(d(L,R)+d(L,k)-d(R,k))/2]==1) location[k]=location[L]+d(L,k),stype[k]=2;
else if (zauz[location[R]-(d(L,R)+d(R,k)-d(L,k))/2]==2) location[k]=location[R]-d(R,k),stype[k]=1;
else if (d(L,R)+d(0,k)-d(0,R)==d(L,k)) location[k]=location[L]+d(L,k),stype[k]=2;
else location[k]=location[R]-d(R,k),stype[k]=1;
zauz[location[k]]=stype[k];
if (location[k]>location[R]) R=k;
if (location[k]<location[L]) L=k;
}
}
컴파일 시 표준 에러 (stderr) 메시지
rail.cpp: In function 'void findLocation(int, int, int*, int*)':
rail.cpp:33:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
33 | for (auto [di,k] : ok)
| ^
# | 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... |