QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#685918 | #8022. Walker | Xunwuqishi | WA | 9ms | 1664kb | C++23 | 3.6kb | 2024-10-28 21:56:43 | 2024-10-28 21:56:56 |
Judging History
answer
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
const int QAQ = 0;
int main()
{
int _;
scanf("%d",&_);
while(_--)
{
double n,a,b,av,bv,ans;
scanf("%lf%lf%lf%lf%lf",&n,&a,&av,&b,&bv);
if(a > b)//找到一个左右的参考点,后续两人视为A和B
{
double t;
t = a;a = b;b = t;
t = av;av = bv;bv = t;
}
ans = 1000000000.0;//把最小的答案初始设置为最大值
if((2 * n - a) / av < ans) ans = (2 * n - a) / av;//考虑A正向起始掉头一次跑完全程
if((2 * n - b) / bv < ans) ans = (2 * n - b) / bv;//考虑B正向起始掉头一次跑完全程
if((a + n) / av < ans) ans = (a + n) / av;//考虑A反向起始掉头一次跑完全程
if((b + n) / bv < ans) ans = (b + n) / bv;//考虑B反向起始掉头一次跑完全程
double t = (b - a) / (av + bv);//考虑相向而行的相对速度并且相遇的时间
double o;
o = 1000000000.0;
if((n - b + t * bv) / av > (a + t * av) / bv) o = t + (n - b + t * bv) / av;
else o = t + (a + t * av) / bv;
if(o < ans) ans = o;//相遇后A到右端,B到左端
if((n - b) / bv > (b + a) / av) o = (n - b) / bv;else o = (b + a) / av;
if(o < ans) ans = o;//a先向左然后到底掉头至b的初始点,b直接向右到底
if(a / av > (n - b + n - a) / bv) o = a / av;else o = (n - b + n - a) / bv;
if(o < ans) ans = o;//b先向右到底然后至a的初始点,a直接向左到底
if((n - b) / bv > (b - a + b - a + a) / av) o = (n - b) / bv;
else o = (b - a + b - a + a) / av;
if(o < ans) ans = o;//a先向右至b的初始点然后折返到底,b直接向右到底
if(a / av > (b - a + b - a + n - b) / bv) o = a / av;
else o = (b - a + b - a + n - b) / bv;
if(o < ans) ans = o;//b先向左至a的初始点然后折返到底,a直接向左到底
if(a / av > (n - b) / bv)
{
double tt = a / av;
double x = tt * bv - (n - b);
double xx = (av * (n - a - x) - a * bv) / (av + bv);
if(tt + (a + xx) / av < ans) ans = tt + (a + xx) / av;
}else
{
double tt = (n - b) / bv;
double x = tt * av - a;
double xx = (av * (n - a) - bv * (a - x)) / (av + bv);
if(tt + (a - x + xx) / av < ans) ans = tt + (a - x + xx) / av;
}//a和b分别往两端移动然后相聚于中间点,涉及简单判断和计算
double xx = (av * (2.0 * (b - a) + n - b) - a * bv) / (2.0 * (av + bv));
if(xx >= 0.0 && xx <= b - a)
{
if((2 * xx + a) / av < ans) ans = (2 * xx + a) / av;
}//b和a分别走向中间然后并未相遇时b折返,a走到b折返的位置后折返
xx = (av * (2.0 * (b - a) + n - b) - 2.0 * a * bv) / (2.0 * av + bv);
if(xx >= 0.0 && xx <= b - a)
{
if((2 * a + xx) / av < ans) ans = (2 * a + xx) / av;
}//a先向左走到底,b向左走一定路程后折返,a到底后折返至b的折返点
xx = ((b - a + 2.0 * (n - b)) * av - a * bv) / (av + 2.0 * bv);
if(xx >= 0.0 && xx <= b - a)
{
if((a + 2 * xx) / av < ans) ans = (a + 2 * xx) / av;
}//b先向右走到底,a往右走到一定位置折返,b走到底后折返走到至a的折返点
//上述最后的三种情况我们可以列出时间t和折返点之间的一个函数关系,可以直接求导得出折返点的坐标位置
printf("%.5lf\n",ans);
}
return QAQ;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1616kb
input:
2 10000.0 1.0 0.001 9999.0 0.001 4306.063 4079.874 0.607 1033.423 0.847
output:
5001000.00000 3827.83700
result:
ok 2 numbers
Test #2:
score: 0
Accepted
time: 0ms
memory: 1592kb
input:
1 10.0 1.0 10.0 9.0 0.1
output:
1.10000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #3:
score: 0
Accepted
time: 0ms
memory: 1608kb
input:
1 10.0 8.0 10.0 9.0 0.1
output:
1.20000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #4:
score: 0
Accepted
time: 0ms
memory: 1644kb
input:
1 10.0 8.0 0.1 9.0 10
output:
1.10000
result:
ok found '1.1000000', expected '1.1000000', error '0.0000000'
Test #5:
score: 0
Accepted
time: 0ms
memory: 1608kb
input:
1 10.0 2.0 0.1 3.0 10
output:
1.30000
result:
ok found '1.3000000', expected '1.3000000', error '0.0000000'
Test #6:
score: 0
Accepted
time: 0ms
memory: 1576kb
input:
1 10.0 9.0 0.1 8.0 10.0
output:
1.20000
result:
ok found '1.2000000', expected '1.2000000', error '0.0000000'
Test #7:
score: 0
Accepted
time: 0ms
memory: 1608kb
input:
1 10.0 4.0 0.1 6.0 0.1
output:
60.00000
result:
ok found '60.0000000', expected '60.0000000', error '0.0000000'
Test #8:
score: 0
Accepted
time: 0ms
memory: 1656kb
input:
1 10.0 4.5 0.1 6.0 0.1
output:
57.50000
result:
ok found '57.5000000', expected '57.5000000', error '0.0000000'
Test #9:
score: 0
Accepted
time: 0ms
memory: 1596kb
input:
1 10.0 1.0 1.0 8.0 1.0
output:
6.50000
result:
ok found '6.5000000', expected '6.5000000', error '0.0000000'
Test #10:
score: 0
Accepted
time: 0ms
memory: 1664kb
input:
1 10.0 3.0 2.0 7.0 1.0
output:
4.60000
result:
ok found '4.6000000', expected '4.6000000', error '0.0000000'
Test #11:
score: 0
Accepted
time: 0ms
memory: 1624kb
input:
1 10.0 6.0 2.0 7.0 1.0
output:
3.66667
result:
ok found '3.6666700', expected '3.6666667', error '0.0000009'
Test #12:
score: 0
Accepted
time: 0ms
memory: 1580kb
input:
1 10.0 1.0 1.0 9.0 1.0
output:
6.00000
result:
ok found '6.0000000', expected '6.0000000', error '0.0000000'
Test #13:
score: 0
Accepted
time: 0ms
memory: 1584kb
input:
1 10000.0 1.0 0.001 1.0 0.001
output:
9999000.00000
result:
ok found '9999000.0000000', expected '9999000.0000000', error '0.0000000'
Test #14:
score: 0
Accepted
time: 0ms
memory: 1652kb
input:
1 10.0 5.0 1.0 5.0 1.5
output:
5.00000
result:
ok found '5.0000000', expected '5.0000000', error '0.0000000'
Test #15:
score: 0
Accepted
time: 6ms
memory: 1616kb
input:
10000 4306.063 4079.874 0.607 1033.423 0.847 8967.336 8026.500 0.398 283.019 0.876 9568.147 4481.616 0.405 800.114 0.684 9867.264 6184.040 0.312 9853.164 0.641 3344.364 730.612 0.539 1305.868 0.947 9336.180 3672.113 0.773 432.686 0.312 1468.243 59.762 0.840 1438.446 0.827 1355.133 1096.314 0.373 109...
output:
3827.83700 7999.36499 12559.33580 15371.55070 2637.69852 9931.04152 934.49430 2939.17962 5754.03289 2847.42716 10975.32363 2180.27861 23747.04545 6278.10355 872.39771 10734.39564 1005.07703 20225.16309 9878.00995 22899.25926 12241.08593 33365.47619 3153.05873 11691.59763 20162.71115 6052.69672 5846....
result:
ok 10000 numbers
Test #16:
score: -100
Wrong Answer
time: 9ms
memory: 1608kb
input:
10000 2030.871 179.860 3.339 226.899 5.608 4013.779 5.483 5.886 2655.711 6.577 2948.361 1567.653 5.641 1789.794 4.572 1539.149 427.003 6.957 936.942 3.945 1689.115 359.356 1.192 742.725 8.260 2381.830 1935.542 7.989 1021.393 9.984 2247.138 2095.797 6.333 411.074 8.188 4141.126 403.006 1.882 3801.489...
output:
321.67832 364.07739 310.43787 186.46604 294.41162 178.52411 193.48206 556.83279 1413.56370 403.23023 743.59151 396.62882 209.13011 611.28507 4769.78107 631.17553 679.60399 2239.79251 672.22649 652.93272 1108.77182 362.00739 602.39813 175.93697 1171.48177 165.12054 510.48568 87.69566 403.76933 1736.4...
result:
wrong answer 1972nd numbers differ - expected: '0.4297319', found: '0.4297300', error = '0.0000019'