QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#250139#7184. Transport Pluseskilo_tobo_tarjen#WA 0ms3920kbC++201.7kb2023-11-12 21:42:552023-11-12 21:42:55

Judging History

你现在查看的是最新测评结果

  • [2023-11-12 21:42:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3920kb
  • [2023-11-12 21:42:55]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long double lf;
struct point{
    lf x,y;
};
const lf inf =1e9;
lf dis(point a,point b){
    return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
point beg,ed;
int n;lf t;
lf cal(vector<pair<int,point>> p){
    if(p.empty())return dis(beg,ed);
    lf res=0;
    for(int i=0;i+1<(int)p.size();i++){
        if(p[i+1].first==0)res+=dis(p[i].second,p[i+1].second);
        else res+=t;
    }
    res+=dis(p[0].second,beg);
    // cout<<p.size()<<"\n";
    // for(auto it:p){
    //     cout<<it.first<<" "<<it.second.x<<" "<<it.second.y<<"\n";
    // }
    // cout<<"res="<<res<<"\n";
    return res;
}
point near(point p,point q){
    if(fabs(p.x-q.x)<fabs(p.y-q.y))return point{q.x,p.y};
    else return point{p.x,q.y};
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>n>>t;
    vector<point> a(n+1);
    cin>>beg.x>>beg.y;
    cin>>ed.x>>ed.y;
    for(int i=1;i<=n;i++)cin>>a[i].x>>a[i].y;
    vector<pair<int,point>> ans;
    for(int i=1;i<=n;i++){
        vector<pair<int,point>> p;
        p.emplace_back(0,near(beg,a[i]));
        p.emplace_back(i,near(ed,a[i]));
        p.emplace_back(0,ed);
        if(cal(p)<cal(ans))ans=p;
    }
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            vector<pair<int,point>> p;
            p.emplace_back(0,near(beg,a[i]));
            p.emplace_back(i,point{a[i].x,a[j].y});
            p.emplace_back(j,near(ed,a[j]));
            p.emplace_back(0,ed);
            if(cal(p)<cal(ans))ans=p;
        }
    }
    cout<<fixed<<setprecision(10)<<cal(ans)<<"\n";
    cout<<ans.size()<<"\n";
    for(auto it:ans){
        cout<<it.first<<" "<<it.second.x<<" "<<it.second.y<<"\n";
    }
}   

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3896kb

input:

1 2
1 1
5 3
6 2

output:

4.0000000000
3
0 1.0000000000 2.0000000000
1 5.0000000000 2.0000000000
0 5.0000000000 3.0000000000

result:

ok correct

Test #2:

score: 0
Accepted
time: 0ms
memory: 3920kb

input:

2 1
1 1
6 1
1 3
6 3

output:

2.0000000000
4
0 1.0000000000 1.0000000000
1 1.0000000000 3.0000000000
2 6.0000000000 1.0000000000
0 6.0000000000 1.0000000000

result:

ok correct

Test #3:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

0 0
1 1
1 1

output:

0.0000000000
0

result:

ok correct

Test #4:

score: -100
Wrong Answer
time: 0ms
memory: 3808kb

input:

0 0
100 100
0 0

output:

141.4213562373
0

result:

wrong answer arrived at (100.000000, 100.000000) instead of (0.000000, 0.000000)