# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
113218 |
2019-05-24T10:51:56 Z |
knon0501 |
None (KOI16_dist) |
C++14 |
|
475 ms |
3044 KB |
#include <bits/stdc++.h>
using namespace std;
int n,t;
#define mp make_pair
#define x first
#define y second
typedef long long ll;
typedef pair<ll,ll> pp;
pp a[300005];
pp v[300005];
pp s[300005];
pp b[300005];
pair<ll,int> ans={8e18+2e17,1e9};
long double f(pp q,pp w,pp e){
ll aa=q.y-w.y;
ll bb=w.x-q.x;
ll cc=q.x*w.y-q.y*w.x;
return (long double)(aa*e.x+bb*e.y+cc)/sqrt((long double)(aa*aa+bb*bb));
}
ll ccw(pp q,pp w,pp e){
return (w.x-q.x)*(e.y-w.y)-(w.y-q.y)*(e.x-w.x);
}
ll dist(pp q,pp w){
return (w.x-q.x)*(w.x-q.x)+(w.y-q.y)*(w.y-q.y);
}
bool comp(pp q,pp w){
ll k=ccw(b[1],q,w);
return k ? k>0 : dist(b[1],q)<dist(b[1],w);
}
ll process(ll ti){
if(ti<0 || ti>t)return 1e18;
int i,j;
ll ret=0;
for(i=1 ; i<=n ; i++)b[i]={a[i].x+ti*v[i].x,a[i].y+ti*v[i].y};
sort(b+1,b+n+1);
sort(b+2,b+n+1,comp);
ret=dist(b[1],b[n]);
int to=2;
s[1]=b[1];
s[2]=b[2];
b[n+1]=b[1];
for(i=3 ; i<=n+1 ; i++){
while(to>=2 && ccw(s[to-1],s[to],b[i])<=0)to--;
s[++to]=b[i];
}
to--;
if(to<3)return ret;
/// cout<<to<<" "<<ti<<endl;
j=2;
for(i=1 ; i<=to ; i++){
int ii=i%to+1;
if(j>to)j=1;
while(f(s[i],s[ii],s[j%to+1])>f(s[i],s[ii],s[j]) ){
ret=max({ret,dist(s[i],s[j]),dist(s[ii],s[j])});
j++;
if(j>to)j=1;
}
ret=max({ret,dist(s[i],s[j]),dist(s[ii],s[j])});
}
/// cout<<ret<<endl;
return ret;
}
int main(){
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
cin>>n>>t;
int i;
for(i=1 ; i<=n ; i++)cin>>a[i].x>>a[i].y>>v[i].x>>v[i].y;
int lef=0;
int rig=t;
while(rig>=lef){
int mid=(lef+rig)/2;
ll q=process(mid-1);
ll w=process(mid);
ll e=process(mid+1);
if(mp(q,mid-1)<ans){
ans={q,mid-1};
}
if(mp(w,mid)<ans){
ans={w,mid};
}
if(mp(e,mid+1)<ans){
ans={e,mid+1};
}
if(q>w && w>e)lef=mid+1;
else rig=mid-1;
}
cout<<ans.second<<endl<<ans.first;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
11 ms |
384 KB |
Output is correct |
12 |
Correct |
12 ms |
512 KB |
Output is correct |
13 |
Correct |
11 ms |
512 KB |
Output is correct |
14 |
Correct |
12 ms |
512 KB |
Output is correct |
15 |
Correct |
11 ms |
384 KB |
Output is correct |
16 |
Correct |
17 ms |
512 KB |
Output is correct |
17 |
Correct |
10 ms |
512 KB |
Output is correct |
18 |
Correct |
8 ms |
512 KB |
Output is correct |
19 |
Correct |
10 ms |
384 KB |
Output is correct |
20 |
Correct |
14 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
105 ms |
1912 KB |
Output is correct |
2 |
Correct |
94 ms |
1836 KB |
Output is correct |
3 |
Correct |
105 ms |
1792 KB |
Output is correct |
4 |
Correct |
91 ms |
2272 KB |
Output is correct |
5 |
Correct |
74 ms |
1792 KB |
Output is correct |
6 |
Correct |
84 ms |
2296 KB |
Output is correct |
7 |
Correct |
76 ms |
2040 KB |
Output is correct |
8 |
Correct |
47 ms |
1792 KB |
Output is correct |
9 |
Correct |
103 ms |
2168 KB |
Output is correct |
10 |
Correct |
100 ms |
1792 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
384 KB |
Output is correct |
2 |
Correct |
2 ms |
384 KB |
Output is correct |
3 |
Correct |
2 ms |
384 KB |
Output is correct |
4 |
Correct |
2 ms |
384 KB |
Output is correct |
5 |
Correct |
2 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
2 ms |
384 KB |
Output is correct |
8 |
Correct |
2 ms |
384 KB |
Output is correct |
9 |
Correct |
2 ms |
384 KB |
Output is correct |
10 |
Correct |
2 ms |
384 KB |
Output is correct |
11 |
Correct |
11 ms |
384 KB |
Output is correct |
12 |
Correct |
12 ms |
512 KB |
Output is correct |
13 |
Correct |
11 ms |
512 KB |
Output is correct |
14 |
Correct |
12 ms |
512 KB |
Output is correct |
15 |
Correct |
11 ms |
384 KB |
Output is correct |
16 |
Correct |
17 ms |
512 KB |
Output is correct |
17 |
Correct |
10 ms |
512 KB |
Output is correct |
18 |
Correct |
8 ms |
512 KB |
Output is correct |
19 |
Correct |
10 ms |
384 KB |
Output is correct |
20 |
Correct |
14 ms |
512 KB |
Output is correct |
21 |
Correct |
105 ms |
1912 KB |
Output is correct |
22 |
Correct |
94 ms |
1836 KB |
Output is correct |
23 |
Correct |
105 ms |
1792 KB |
Output is correct |
24 |
Correct |
91 ms |
2272 KB |
Output is correct |
25 |
Correct |
74 ms |
1792 KB |
Output is correct |
26 |
Correct |
84 ms |
2296 KB |
Output is correct |
27 |
Correct |
76 ms |
2040 KB |
Output is correct |
28 |
Correct |
47 ms |
1792 KB |
Output is correct |
29 |
Correct |
103 ms |
2168 KB |
Output is correct |
30 |
Correct |
100 ms |
1792 KB |
Output is correct |
31 |
Correct |
435 ms |
2532 KB |
Output is correct |
32 |
Correct |
428 ms |
2304 KB |
Output is correct |
33 |
Correct |
408 ms |
2424 KB |
Output is correct |
34 |
Correct |
423 ms |
2432 KB |
Output is correct |
35 |
Correct |
306 ms |
2432 KB |
Output is correct |
36 |
Correct |
462 ms |
3044 KB |
Output is correct |
37 |
Correct |
282 ms |
2680 KB |
Output is correct |
38 |
Correct |
174 ms |
2560 KB |
Output is correct |
39 |
Correct |
304 ms |
2564 KB |
Output is correct |
40 |
Correct |
430 ms |
2556 KB |
Output is correct |
41 |
Correct |
475 ms |
2960 KB |
Output is correct |
42 |
Correct |
416 ms |
3020 KB |
Output is correct |