QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#232290#7184. Transport Plusesspetar4WA 1ms3696kbC++143.1kb2023-10-30 09:32:332023-10-30 09:32:34

Judging History

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

  • [2023-10-30 09:32:34]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3696kb
  • [2023-10-30 09:32:33]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;



int main()
{
    int n,t;
    cin>>n>>t;
    int xh, yh;
    cin>>xh>>yh;
    int xe, ye;
    cin>>xe>>ye;
    int x[n+1];
    int y[n+1];
    for (int i=1; i<=n; ++i){cin>>x[i]>>y[i];}

    double mine=sqrt((xe-xh)*(xe-xh)+(ye-yh)*(ye-yh));
    int br=1;
    double pl[400];
    double xx[400];
    double yy[400];
    pl[0]=0;
    xx[0]=xe;
    yy[0]=ye;
    for (int i=1; i<=n; ++i){
        double tr=min(abs(yh-y[i]), abs(xh-x[i])) + min(abs(ye-y[i]), abs(xe-x[i])) + t;
        //cout<<tr<<endl;
        if (tr<mine){
            mine=tr;
            br=3;
            pl[0]=0;
            pl[1]=i;
            pl[2]=0;
            xx[2]=xe;
            yy[2]=ye;
        }
        if (abs(xh-x[i])<abs(yh-y[i]) && abs(xe-x[i])<abs(ye-y[i])){
                xx[0]=x[i];
                yy[0]=yh;
                xx[1]=x[i];
                yy[1]=ye;
        }
        else if (abs(xh-x[i])<abs(yh-y[i]) && abs(xe-x[i])>=abs(ye-y[i])){
                xx[0]=x[i];
                yy[0]=yh;
                xx[1]=xe;
                yy[1]=y[i];
        }
        else if (abs(xh-x[i])>=abs(yh-y[i]) && abs(xe-x[i])<abs(ye-y[i])){
                xx[0]=xh;
                yy[0]=y[i];
                xx[1]=x[i];
                yy[1]=ye;
        }

        else if (abs(xh-x[i])>=abs(yh-y[i]) && abs(xe-x[i])>=abs(ye-y[i])){
                xx[0]=xh;
                yy[0]=y[i];
                xx[1]=xe;
                yy[1]=y[i];
        }
    }

    for (int i=1; i<=n; ++i){
        for (int j=1; j<=n; ++j){
            double tr=min(abs(yh-y[i]), abs(xh-x[i])) + min(abs(ye-y[j]), abs(xe-x[j])) + 2*t;
            //cout<<tr<<endl;
            if (tr<mine){
                mine=tr;
                br=4;
                pl[0]=0;
                pl[1]=i;
                pl[2]=j;
                pl[3]=0;
                xx[3]=xe;
                yy[3]=ye;
                xx[1]=x[i];
                yy[1]=y[j];
                if (abs(xh-x[i])<abs(yh-y[i]) && abs(xe-x[j])<abs(ye-y[j])){
                    xx[0]=x[i];
                    yy[0]=yh;
                    xx[2]=x[j];
                    yy[2]=ye;
                }
                else if (abs(xh-x[i])<abs(yh-y[i]) && abs(xe-x[j])>=abs(ye-y[j])){
                    xx[0]=x[i];
                    yy[0]=yh;
                    xx[2]=xe;
                    yy[2]=y[j];
                }
                else if (abs(xh-x[i])>=abs(yh-y[i]) && abs(xe-x[j])<abs(ye-y[j])){
                    xx[0]=xh;
                    yy[0]=y[i];
                    xx[2]=x[j];
                    yy[2]=ye;
                }
                else if (abs(xh-x[i])>=abs(yh-y[i]) && abs(xe-x[j])>=abs(ye-y[j])){
                    xx[0]=xh;
                    yy[0]=y[i];
                    xx[2]=xe;
                    yy[2]=y[j];
                }
            }
        }
    }

    cout<<mine<<endl;
    cout<<br<<endl;
    for (int i=0; i<br-1; ++i){cout<<pl[i]<<" "<<xx[i]<<" "<<yy[i]<<endl;}
    cout<<0<<" "<<xe<<" "<<ye;
    return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3660kb

input:

1 2
1 1
5 3
6 2

output:

4
3
0 1 2
1 5 2
0 5 3

result:

ok correct

Test #2:

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

input:

2 1
1 1
6 1
1 3
6 3

output:

2
4
0 1 1
1 1 3
2 6 1
0 6 1

result:

ok correct

Test #3:

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

input:

0 0
1 1
1 1

output:

0
1
0 1 1

result:

ok correct

Test #4:

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

input:

0 0
100 100
0 0

output:

141.421
1
0 0 0

result:

ok correct

Test #5:

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

input:

1 0
100 100
0 0
100 100

output:

100
3
0 100 100
1 0 100
0 0 0

result:

ok correct

Test #6:

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

input:

1 0
100 100
0 0
100 0

output:

0
3
0 100 100
1 0 0
0 0 0

result:

ok correct

Test #7:

score: 0
Accepted
time: 1ms
memory: 3628kb

input:

1 0
100 100
0 0
0 100

output:

0
3
0 100 100
1 0 0
0 0 0

result:

ok correct

Test #8:

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

input:

1 100
50 50
0 0
50 50

output:

70.7107
1
0 0 0

result:

ok correct

Test #9:

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

input:

1 100
50 50
0 0
0 50

output:

70.7107
1
0 0 0

result:

ok correct

Test #10:

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

input:

1 100
50 50
0 0
51 51

output:

70.7107
1
0 0 0

result:

ok correct

Test #11:

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

input:

1 100
50 50
0 0
2 53

output:

70.7107
1
0 0 0

result:

ok correct

Test #12:

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

input:

1 100
0 0
100 100
50 50

output:

141.421
1
0 100 100

result:

ok correct

Test #13:

score: 0
Accepted
time: 1ms
memory: 3656kb

input:

1 33
0 0
100 100
50 50

output:

133
3
0 0 50
1 100 50
0 100 100

result:

ok correct

Test #14:

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

input:

1 12
100 0
11 90
0 100

output:

122
3
0 100 100
1 11 100
0 11 90

result:

ok correct

Test #15:

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

input:

1 12
100 0
10 89
0 100

output:

122
3
0 100 100
1 0 89
0 10 89

result:

ok correct

Test #16:

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

input:

2 1
2 1
5 1
1 3
6 3

output:

3
1
0 5 1

result:

ok correct

Test #17:

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

input:

2 2
2 1
5 1
1 3
6 3

output:

3
1
0 5 1

result:

ok correct

Test #18:

score: 0
Accepted
time: 1ms
memory: 3652kb

input:

1 2
1 1
5 3
7 2

output:

4
3
0 1 2
1 5 2
0 5 3

result:

ok correct

Test #19:

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

input:

1 2
1 1
5 4
6 2

output:

4
3
0 1 2
1 6 4
0 5 4

result:

ok correct

Test #20:

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

input:

12 1
77 80
76 78
77 81
76 79
77 78
75 80
75 79
76 80
78 81
77 81
76 81
76 80
77 79
76 79

output:

1
3
0 77 79
3 76 78
0 76 78

result:

wrong answer claimed 1.0000000000, actual 2.0000000000