# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
60650 | reality | 도시들 (IOI15_towns) | C++17 | 38 ms | 876 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "towns.h"
#include "bits/stdc++.h"
using namespace std;
#define fi first
#define se second
#define ll long long
#define dbg(v) cerr<<#v<<" = "<<v<<'\n'
#define vi vector<int>
#define vl vector <ll>
#define pii pair<int,int>
#define mp make_pair
#define db long double
#define pb push_back
#define all(s) s.begin(),s.end()
template < class T > T smin(T &a,T b) {if (a > b) a = b;return a;}
template < class T > T smax(T &a,T b) {if (a < b) a = b;return a;}
const int N = 256;
int D[N][N];
int get(int x,int y) {
if (D[x][y] != -1)
return D[x][y];
return D[x][y] = D[y][x] = getDistance(x,y);
}
int hubDistance(int n, int sub) {
srand(time(0));
const int root = 0;
memset(D,-1,sizeof(D));
int x = 0;
for (int i = 0;i < n;++i)
D[i][i] = 0;
for (int i = 0;i < n;++i)
if (get(root,i) > get(root,x))
x = i;
int y = x;
for (int i = 0;i < n;++i)
if (get(x,i) > get(x,y))
y = i;
vi s;
for (int k = 0;k < n;++k)
s.pb((get(root,x) - get(root,k) + get(x,k)) / 2);
sort(all(s));
int dist = -1;
int ans = 2e9;
for (auto it : s)
smin(ans,max(it,get(x,y) - it));
for (auto it : s)
if (max(it,get(x,y) - it) == ans)
dist = it;
int a = 0,b = 0;
vi was(n,0);
for (int k = 0;k < n;++k) {
int df = get(x,k) - get(root,k);
int sm = get(root,x);
if (df + sm < 2 * dist)
was[k] = 1,++a;
else
if (df + sm > 2 * dist)
was[k] = 1,++b;
}
if (max(a,b) > (n / 2))
return -ans;
vi v;
auto ok = [&](int A,int B) {
return get(A,B) != get(A,x) + get(B,x) - 2 * dist;
};
for (int i = 0;i < n;++i)
if (!was[i]) {
was[i] = 1;
int cnt = 1;
for (int j = i + 1;cnt <= (n / 2) && j < n;++j)
if (!was[j] && ok(i,j))
++cnt,was[j] = 1;
if (cnt > (n / 2))
return -ans;
}
return ans;
}
컴파일 시 표준 에러 (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... |