QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#236367#7184. Transport PlusesUFRJ#WA 4ms216884kbC++203.9kb2023-11-03 21:44:502023-11-03 21:44:50

Judging History

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

  • [2023-11-03 21:44:50]
  • 评测
  • 测评结果:WA
  • 用时:4ms
  • 内存:216884kb
  • [2023-11-03 21:44:50]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;
using lint = int64_t;

using dbl = double;

const int inf = numeric_limits<int>::max() / 4;

const int N = 100;

int same_plus[N+2][N+2][N+2][N+2];
bool any_plus[N+2][N+2];


int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n, t;
    cin>>n>>t;
    int xh, yh;
    int xe, ye;

    cin>>xh>>yh>>xe>>ye;
    const int inf = 3*t;


   
    vector<pair<int, int>> plus(n);
    for(int id = 0; id < n; id++){
        auto &[x,y] = plus[id];
        cin>>x>>y;
        vector<pair<int, int>> v;
        v.reserve(2*n);
        for(int i =0; i<=N; i++){
            v.emplace_back(i, y);
            v.emplace_back(x, i);
        }
        for(auto [a, b] : v){
            any_plus[a][b] = id + 1;
            for(auto [c, d] : v){
                same_plus[a][b][c][d] = id+1;
            }
        }
    }
    dbl ans = sqrtl((xh - xe)*(xh - xe) + (yh - ye)*(yh - ye));

    for(int a = 0; a<=N; a++)
        for(int b = 0; b <= N; b++)
            for(int c = 0; c <= N; c++)
                for(int d = 0; d <= N; d++){
                    if(!any_plus[a][b] || !any_plus[c][d]) continue;
                    dbl D = 2*t;
                    if(same_plus[a][b][c][d]) D = t;
                    if(a == c && b == d) D = 0;

                    dbl H = sqrtl((xh - a)*(xh - a) + (yh - b)*(yh - b));
                    if(same_plus[xh][yh][a][b]) H = min<dbl>(H, t);
                    dbl E = sqrtl((c - xe)*(c - xe) + (d - ye)*(d - ye));
                    if(same_plus[xe][ye][c][d]) E = min<dbl>(E, t);
                    dbl cur = H + D + E;
                        ans = min(ans, cur);
                }
    cout<<fixed<<setprecision(4)<<ans<<"\n";

    for(int a = 0; a<=N; a++)
        for(int b = 0; b <= N; b++)
            for(int c = 0; c <= N; c++)
                for(int d = 0; d <= N; d++){
                    if(!any_plus[a][b] || !any_plus[c][d]) continue;
                    dbl D = 2*t;
                    if(same_plus[a][b][c][d]) D = t;
                    if(a == c && b == d) D = 0;

                    dbl H = sqrtl((xh - a)*(xh - a) + (yh - b)*(yh - b));
                    if(same_plus[xh][yh][a][b]) H = min<dbl>(H, t);
                    dbl E = sqrtl((c - xe)*(c - xe) + (d - ye)*(d - ye));
                    if(same_plus[xe][ye][c][d]) E = min<dbl>(E, t);
                    dbl cur = H + D + E;
                        ans = min(ans, cur);
                    if(cur == ans){
                        vector<tuple<int, int, int>> answer;
                        if(H == t){
                            answer.emplace_back(same_plus[xh][yh][a][b], a, b);
                        }
                        else {
                            answer.emplace_back(0, a, b);
                        }
                        if(D == 2*t){
                            int P1 = any_plus[a][b];
                            int P2 = any_plus[c][d];
                            answer.emplace_back(P1, plus[P1].first, plus[P2].second);
                            answer.emplace_back(P2, plus[P2].first, plus[P2].second);                            
                        }
                        else if(D == t) {
                            answer.emplace_back(same_plus[a][b][c][d], c, d);
                        }
                        if(E == t){
                            answer.emplace_back(same_plus[c][d][xe][ye], xe, ye);   
                        }
                        else  {
                            answer.emplace_back(0, xe, ye);   
                        }
                        cout<<answer.size()<<"\n";
                        for(auto [p, x, y] : answer) cout<<p<<" "<<x<<" "<<y<<"\n";
                        return 0;
                    }
                }
    cout<<"1\n";
    cout<<"0 "<<xe<<" "<<ye<<"\n";

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 214772kb

input:

1 2
1 1
5 3
6 2

output:

4.0000
3
0 1 2
1 5 2
0 5 3

result:

ok correct

Test #2:

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

input:

2 1
1 1
6 1
1 3
6 3

output:

2.0000
2
1 0 3
2 6 1

result:

ok correct

Test #3:

score: 0
Accepted
time: 2ms
memory: 3796kb

input:

0 0
1 1
1 1

output:

0.0000
1
0 1 1

result:

ok correct

Test #4:

score: 0
Accepted
time: 2ms
memory: 3784kb

input:

0 0
100 100
0 0

output:

141.4214
1
0 0 0

result:

ok correct

Test #5:

score: -100
Wrong Answer
time: 3ms
memory: 216884kb

input:

1 0
100 100
0 0
100 100

output:

100.0000
4
1 0 100
1 0 0
1 0 0
0 0 0

result:

wrong answer step 2: target (0.000000, 0.000000) not on plus (100.000000, 100.000000)