| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1030993 | 12345678 | Towns (IOI15_towns) | C++17 | 14 ms | 980 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "towns.h"
#include <bits/stdc++.h>
using namespace std;
int hubDistance(int N, int sub) {
vector<int> d[N];
pair<int, int> mx={0, 0};
int l=0, r, mn=INT_MAX;
vector<int> dl(N), dr(N), dh(N);
for (int i=1; i<N;i ++) dl[i]=getDistance(0, i), mx=max(mx, {dl[i], i});
r=mx.second;
dr[l]=dl[r];
for (int i=0; i<N;i ++) if (i!=l&&i!=r) dr[i]=getDistance(r, i);
int dist=dl[r];
map<int, int> mp;
map<int, vector<int>> mpd;
for (int i=0; i<N; i++)
{
int x=dl[i], y=dr[i], h=(x+dist-y)/2;
dh[i]=(x+y-dist)/2;
if (mp.find(h)==mp.end()) mp[h]=dh[i];
else mp[h]=max(mp[h], dh[i]);
mpd[h].push_back(i);
}
for (auto [x, a]:mp)
{
int mx=a;
for (auto [y, b]:mp) mx=max(mx, abs(x-y)+b);
mn=min(mn, mx);
}
int sz=0, can=-1;
for (auto [x, a]:mp)
{
int mx=a;
for (auto [y, b]:mp) mx=max(mx, abs(x-y)+b);
if (mn==mx)
{
if (sz<=(N/2)&&(N-sz-(int)mpd[x].size()<=(N/2)))
{
if (((int)mpd[x].size())<=(N/2)) can=1;
else
{
int lst=0, freq=0;
for (auto idx:mpd[x])
{
if (freq==0)
{
freq++;
lst=idx;
}
else
{
if (getDistance(idx, lst)!=(dh[idx]+dh[lst])) d[lst].push_back(idx), freq++;
else freq--;
}
}
vector<int> vs(N);
int cnt=d[lst].size()+1;
vs[lst]=1;
for (auto idx:d[lst]) vs[idx]=1;
for (auto idx:mpd[x])
{
if (vs[idx]) continue;
if (getDistance(lst, idx)!=(dh[idx]+dh[lst]))
{
cnt+=1+d[idx].size();
vs[idx]=1;
for (auto y:d[idx]) vs[y]=1;
}
}
if (cnt<=(N/2)) can=1;
}
}
}
sz+=mpd[x].size();
}
return mn*can;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | 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... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
