QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#103917 | #5667. Meeting Places | Robert_JYH# | WA | 4ms | 10012kb | C++17 | 3.1kb | 2023-05-07 20:45:55 | 2023-05-07 20:45:57 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=(1LL<<31)-1;
const int N=2005;
int n,k;
ll X[N],Y[N];
void gen(){
for(int i=1;i<=n;i++){
if(i>1)X[i]=(Y[i-1]*233811181+1)%mod;
Y[i]=(X[i]*233811181+1)%mod;
}
}
const double pi=acos(-1.0);
const double eps=1e-8;
int sign(double x){
if(fabs(x)<eps)return 0;
return (x<0)?-1:1;
}
int dcmp(double x,double y){return sign(x-y);}
struct Point{
double x,y;
Point(double X=0,double Y=0):x(X),y(Y){}
Point operator + (const Point &r) const{return Point(x+r.x,y+r.y);}
Point operator - (const Point &r) const{return Point(x-r.x,y-r.y);}
Point operator * (double p) const{return Point(x*p,y*p);}
Point operator / (double p) const{return Point(x/p,y/p);}
};
double dot(Point A,Point B){return A.x*B.x+A.y*B.y;}
double length(Point A){return sqrt(dot(A,A));};
double dis(Point A,Point B){return length(A-B);}
double cross(Point A,Point B){return A.x*B.y-A.y*B.x;}
Point rotate(Point A,double rad){
return Point(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
}
struct Line{
Point a,b;
Point v;
Line(){}
Line(const Point &A,const Point &B,int op=0){
if(!op){a=A,b=B,v=b-a;}
else{a=A,v=B;b=a+v;}
}
Point point(double p){return a+v*p;}
};
Point line_line_inter(Line x,Line y){
Point U=x.a-y.a;
double t=cross(y.v,U)/cross(x.v,y.v);
return x.a+x.v*t;
}
struct Circle{
Point o;
double r;
Circle(){}
Circle(const Point &O,double R):o(O),r(R){}
bool inc(const Point &p){
return dcmp(r,dis(o,p))>=0;
}
};
Line get_line(Point a,Point b){return Line((a+b)/2,rotate(b-a,pi/2),1);}
Circle get_circle(Point a,Point b,Point c){
Line u=get_line(a,b),v=get_line(a,c);
Point o=line_line_inter(u,v);
return Circle(o,dis(o,a));
}
Point p[N];
double R[N][N];
void min_circle(int l,int r){
Circle c=Circle(p[l],0);
for(int i=l;i<=r;i++){
if(!c.inc(p[i])){
c=Circle(p[i],0);
for(int j=l;j<i;j++)
if(!c.inc(p[j])){
c=Circle((p[i]+p[j])/2,dis(p[i],p[j])/2);
for(int k=l;k<j;k++)
if(!c.inc(p[k]))
c=get_circle(p[i],p[j],p[k]);
}
}
R[l][i]=c.r;
}
}
vector<int>trans[N];
double f[N][N];
int main(){
cin>>n>>k>>X[1];
gen();
for(int i=1;i<=n;i++)p[i]=Point(X[i],Y[i]);
for(int i=1;i<=n;i++)min_circle(i,n);
for(int i=1;i<=n;i++){
for(int j=i;j;j--){
if(R[j][i]!=R[j-1][i])
trans[i].push_back(j);
}
}
for(int i=1;i<=n;i++)
for(int j=0;j<=k;j++)
f[i][j]=1e16;
for(int i=1;i<=n;i++)
for(int j=1;j<=min(i,k);j++)
for(auto o:trans[i]){
f[i][j]=min(f[i][j],f[o-1][j-1]+R[o][i]);
// cout<<i<<" "<<j<<" "<<f[i][j]<<" "<<o-1<<" "<<j-1<<" "<<f[o-1][j-1]<<" "<<R[o][i]<<endl;
}
printf("%.10lf\n",f[n][k]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 4ms
memory: 10012kb
input:
100 23 213
output:
1319350480.8007326126
result:
ok found '1319350480.8007326', expected '1319350480.8007326', error '0.0000000'
Test #2:
score: 0
Accepted
time: 0ms
memory: 5692kb
input:
10 1 1060
output:
1042753143.3451676369
result:
ok found '1042753143.3451676', expected '1042753143.3451676', error '0.0000000'
Test #3:
score: -100
Wrong Answer
time: 2ms
memory: 5872kb
input:
10 10 2373
output:
510280442.6665264964
result:
wrong answer 1st numbers differ - expected: '0.0000000', found: '510280442.6665265', error = '510280442.6665265'