QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#626069 | #7003. Rikka with Minimum Spanning Trees | ucup-team5071# | WA | 0ms | 3624kb | C++20 | 3.2kb | 2024-10-09 22:56:13 | 2024-10-09 22:56:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long double lf;
struct kkk{
int x,y,tx,ty;
// x,y,
// t=0 说明在那个点的左边的边上
// t=1 说明在点上
lf len;
bool operator<(kkk k1)const{
return len>k1.len;
}
};
lf read(){
int x;cin>>x;return (lf)x;
}
lf cal(lf h1,lf h2,lf s,lf t){
if(h1>h2)swap(h1,h2);
if(s>t)swap(s,t);
if((s>=h1&&t<=h2)){
if(h1==h2)return 1.;
else {
lf delta=h2-h1;
lf len=sqrt(1.+delta*delta);
return len/delta*(t-s);
}
}
else return -1.;
}
const lf inf=1e18;
lf dis[52][2][52][2];
lf solve(){
int n;cin>>n;
vector<lf>a(n+1);
for(int i=0;i<=n;i++)a[i]=read();
for(int i=0;i<=n;i++){
for(int x=0;x<2;x++)
for(int j=0;j<=n;j++)
for(int y=0;y<2;y++)dis[i][x][j][y]=inf;
}
priority_queue<kkk,vector<kkk>> qu;
auto push = [&](int x,int tx,int y,int ty,lf len){
if(dis[x][tx][y][ty]==inf)qu.push(kkk{x,tx,y,ty,len});
};
// t=0 说明在那个点的左边的边上
// t=1 说明在点上
push(0,1,n,1,0);
lf ans=inf;
while(!qu.empty()){
kkk k1=qu.top();qu.pop();
int x=k1.x,y=k1.y,tx=k1.tx,ty=k1.ty,len=k1.len;
if(dis[x][tx][y][ty]!=inf)continue;
dis[x][tx][y][ty]=len;
dis[y][ty][x][tx]=len;
if(a[x]==a[y])push(x,1,y,1,len);
if(tx==1&&ty==1){
auto solve=[&](){
if(x>0){// <-x
if(a[x]==a[x-1])push(x-1,1,y,ty,len+1.);
else{
if(y<n){ //y->
if(a[x-1]>a[x]&&a[y-1]>a[y]&&a[y-1]>=a[x-1]){
}
}
if(y>0){// <-y
}
}
}
};
solve();
swap(x,y);
swap(tx,ty);
solve();
}
else {
auto solve=[&](){
if(x>0){// <-x
if(a[x]==a[x-1])push(x-1,1,y,ty,len+1.);
else{
if(y<n){ //y->
if(a[x-1]>a[x]&&a[y-1]>a[y]&&a[y-1]>=a[x-1]){
}
}
if(y>0){// <-y
}
}
}
};
solve();
swap(x,y);
swap(tx,ty);
solve();
}
}
for(int i=0;i<=n;i++)ans=min(ans,dis[i][1][i][1]*2);
return ans;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(15);
int T;cin>>T;
while(T--)solve();
}
/*
4
4
0 1 1 2 0
4
0 2 1 3 0
4
0 1 2 1 0
4
0 2 1 2 0
*/
/*
12.128990204491960
22.313624568639947
*/
/*
1
3
0 2 2 0
*/
/*
1
4
0 1 1 2 0
*/
/*
6
4
0 2 0 2 0
6
0 1 0 1 0 1 0
6
0 1 0 2 0 1 0
6
0 2 0 1 0 2 0
6
0 2 0 2 0 1 0
5
0 2 2 0 1 0
17.888
16.970
20.2579
23.545
28.017
21.0732
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3624kb
input:
1 2 100000 123456789 987654321
output:
result:
wrong answer 1st lines differ - expected: '575673759', found: ''