QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#232284 | #7184. Transport Pluses | spetar4 | WA | 1ms | 3768kb | C++14 | 3.1kb | 2023-10-30 09:23:22 | 2023-10-30 09:23:22 |
Judging History
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; ++i){cout<<pl[i]<<" "<<xx[i]<<" "<<yy[i]<<endl;}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3584kb
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: 3596kb
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: 1ms
memory: 3656kb
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: 3768kb
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: 3660kb
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: 0ms
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: -100
Wrong Answer
time: 0ms
memory: 3576kb
input:
1 100 50 50 0 0 50 50
output:
70.7107 1 0 50 50
result:
wrong answer arrived at (50.000000, 50.000000) instead of (0.000000, 0.000000)