# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
302394 | square1001 | Towns (IOI15_towns) | C++14 | 23 ms | 896 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "towns.h"
#include <cmath>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int hubDistance(int N, int sub) {
if(sub <= 2) {
vector<int> da(N);
for(int i = 1; i < N; ++i) {
da[i] = getDistance(0, i);
}
int ma = max_element(da.begin(), da.end()) - da.begin();
vector<int> db(N);
for(int i = 0; i < N; ++i) {
if(i != ma) {
db[i] = getDistance(ma, i);
}
}
int mb = max_element(db.begin(), db.end()) - db.begin();
int mindiff = (1 << 30);
for(int i = 0; i < N; ++i) {
if(i != ma && i != mb) {
int dx = getDistance(ma, i);
int dy = getDistance(mb, i);
mindiff = min(mindiff, abs(dx - dy));
}
}
return (db[mb] + mindiff) / 2;
}
else {
// write code here
}
return 0;
}
Compilation message (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... |