QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#745778 | #5667. Meeting Places | FreeTimeLove | WA | 1ms | 8012kb | C++14 | 2.3kb | 2024-11-14 11:34:00 | 2024-11-14 11:34:01 |
Judging History
answer
/*FreeTimeLove's code.
Love has a nasty habit of disappearing over night.*/
#include<bits/stdc++.h>
namespace FRTMLV{
#define ll long long
#define LD long double
#define i7 __int128
#define re return
#define con continue
using namespace std;
template<class T>inline bool ckmin(T &a,T b){re b<a?a=b,1:0;}
template<class T>inline bool ckmax(T &a,T b){re a<b?a=b,1:0;}
const int N=2e3+5;
inline int rd(){
int ans=0,f=0;
char ch=getchar();
while(ch<'0'||ch>'9')f^=(ch=='-'),ch=getchar();
while(ch>='0'&&ch<='9')ans=(ans<<3)+(ans<<1)+(ch^48),ch=getchar();
re f?-ans:ans;
}
mt19937 rnd(chrono::system_clock::now().time_since_epoch().count());
int n,K;
LD eps=1e-10;
struct node{
LD x,y;
}a[N];
node operator +(node a,node b){re {a.x+b.x,a.y+b.y};}
node operator -(node a,node b){re {a.x-b.x,a.y-b.y};}
node operator *(node a,LD b){re {a.x*b,a.y*b};}
LD operator *(node a,node b){re a.x*b.y-b.x*a.y;}
inline LD dis(node a,node b){re sqrtl((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}
inline node gtm(node a,node b){re (a+b)*0.5;}
inline node gto(node &a,node &b,node &c){
node m1=gtm(a,b),m2=gtm(a,c);
node k1={a.y-b.y,b.x-a.x},k2={a.y-c.y,c.x-a.x};
node dm=m1-m2;
LD dx=(dm*k2)/(k2*k1);
re m1+(k1*dx);
}
LD dp[N][N];
void sol(int n){
node o=a[n];
LD r=0;
for(int i=1;i<=K;i++)ckmin(dp[n][i],dp[n-1][i-1]);
for(int i=n-1;i;i--){
if(i<=K){
ckmin(dp[n][i],dp[i-1][i-1]+r);
}
if(dis(o,a[i])<r+eps)con;
for(int j=1;j<=K;j++)ckmin(dp[n][j],dp[i][j-1]+r);
o=a[i],r=0;
for(int j=n;j>i;j--){
if(dis(o,a[j])<r+eps)con;
o=gtm(a[i],a[j]),r=dis(o,a[i]);
for(int k=n;k>j;k--){
if(dis(o,a[k])<r+eps)con;
o=gto(a[i],a[j],a[k]),r=dis(o,a[i]);
}
}
for(int j=1;j<=K;j++)ckmin(dp[n][j],dp[i-1][j-1]+r);
}
for(int j=1;j<=K;j++)ckmin(dp[n][j],dp[0][j-1]+r);
}
inline ll inc(ll x){re (x*233811181+1)%((1ll<<31)-1);}
int main(){
n=rd(),K=rd();
a[1].x=rd(),a[1].y=inc(a[1].x);
for(int i=2;i<=n;i++)a[i].x=inc(a[i-1].y),a[i].y=inc(a[i].x);
for(int i=0;i<=n;i++)
for(int j=0;j<=K;j++)dp[i][j]=0x3f3f3f3f3f3f3f3f;
dp[0][0]=0;
for(int i=1;i<=n;i++)sol(i);
printf("%.12Lf\n",dp[n][K]);
// for(int i=0;i<=n;i++){
// for(int j=0;j<=K;j++)printf("%.3Lf ",dp[i][j]);puts("");
// }
re 0;
}
/*
3 2 1
100 23 213
*/
}int main(){re FRTMLV::main();}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 8012kb
input:
100 23 213
output:
1319350480.800732538686
result:
ok found '1319350480.8007326', expected '1319350480.8007326', error '0.0000000'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 5816kb
input:
10 1 1060
output:
1031863952.104010022245
result:
wrong answer 1st numbers differ - expected: '1042753143.3451676', found: '1031863952.1040100', error = '0.0104427'