# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
31185 | leejseo | 먼 별 (KOI16_dist) | C++98 | 2000 ms | 1584 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 <stdio.h>
#include <algorithm>
using namespace std;
typedef struct {
int x, y, dx, dy;
} star;
#define MAX_T 10000000
#define MAX_N 30000
star L[MAX_N];
int n, T;
long long int dist(star &a, star &b, int t){
long long int a_x = a.x + t*a.dx;
long long int a_y = a.y + t*a.dy;
long long int b_x = b.x + t*b.dx;
long long int b_y = b.y + t*b.dy;
return (a_x - b_x)*(a_x - b_x) + (a_y - b_y) * (a_y - b_y);
}
long long int g(int t){
long long cnt = 0;
for(int i=0; i<n; i++){
for(int j=0; j<i; j++){
long long temp = dist(L[i], L[j], t);
if (temp > cnt){
cnt = temp;
}
}
}
return cnt;
}
int f(){
int lo = 0;
int hi = T;
while (lo <= hi){
int llh = (2*lo + hi)/3;
int lhh = (lo + 2*hi)/3;
if (g(llh) <= g(lhh)) hi = lhh - 1;
else lo = llh+1;
}
return lo;
}
int main(){
scanf("%d%d", &n, &T);
for (int i=0; i<n; i++){
scanf("%d%d%d%d", &(L[i].x), &(L[i].y), &(L[i].dx), &(L[i].dy));
}
int day = f();
long long d = g(day);
printf("%d\n", day);
printf("%lld\n", d);
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... |