QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#646307#8022. Walkerkans2298WA 0ms3916kbC++172.7kb2024-10-16 22:09:222024-10-16 22:09:24

Judging History

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

  • [2024-10-16 22:09:24]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3916kb
  • [2024-10-16 22:09:22]
  • 提交

answer

#include<cstdio>
#include<iostream>
#include<algorithm>
#include<iomanip>
using namespace std;
using i64=long long;
int main()
{
     int ti,t;
     //freopen("input.in","r",stdin);
     ios::sync_with_stdio(false);
     cin.tie(nullptr);
     cin>>t;
     for (ti=1;ti<=t;++ti)
     {
     double n_,p1_,p2_,n1_,n2_;
     cin>>n_>>p1_>>n1_>>p2_>>n2_;
     i64 n=n_*1000,p1=p1_*1000,p2=p2_*1000,n1=n1_*1000,n2=n2_*1000;
     i64 l=0,r=1e14;
     //cout<<n<<" "<<p1<<" "<<p2<<" "<<n1<<" "<<n2<<"\n";
     if (not (p1<=p2))
          {
          swap(p1,p2);
          swap(n1,n2);
          }
     while (l<r)
          {
          i64 mid=(l+r)>>1;
          auto check1=[](i64 n,i64 p1,i64 p2,i64 n1,i64 n2,i64 x) -> bool {
               double realt=x*1.0/1e7;
               if (1.0*(n+min(p1,n-p1))/n1<=realt) return true;
               if (1.0*(n+min(p2,n-p2))/n2<=realt) return true;

               double ft=min(1.0*(n-p2)/n2,1.0*(n-p1)/n1); //the first time touch right wall
               if (1.0*(n-p1)/n1<=1.0*(n-p2)/n2) //Point A first touch, Point AB both turn left
                    {
                    double tA=1.0*n/p1;
                    double posB=p2+ft*n2;
                    double tB=posB/p2;
                    double ft2=min(tA,tB); //the time cover (0~pos1)
                    if (ft+ft2<=realt) return true;
                    }
               else //Point B first touch, consider two situations
                    { //lack (0~pos1) and (posA~pos2)
                    double ft2=1.0*(p2+min(p1,p2-p1))/n1; //Point A cover (0~p2)
                    if (max(ft,ft2)<=realt) return true; //the situation 1

                    double posA=p1+ft*n1;
                    double tA=posA/n1;
                    double tB;
                    if (posA<p2) tB=(n-posA)/n2;
                         else tB=0;
                    if (max(tA,tB)+ft<=realt) return true;
                    }
               return false;
          };
          auto check2=[](i64 n,i64 p1,i64 p2,i64 n1,i64 n2,i64 x) -> bool {
               double realt=x*1.0/1e7;
               double ft=1.0*(p2-p1)/(n1+n2);
               double posA=p1+n1*ft;  //the Point AB are in same place
               double ft2=max(posA/n1,(n-posA)/n2);
               if (ft+ft2<=realt) return true;

               if (1.0*(n+p1+(n-p2))/(n1+n2)<=realt) return true;
               return false;

          };
          if (check1(n,p1,p2,n1,n2,mid) || check1(n,n-p2,n-p1,n2,n1,mid) ||
               check2(n,p1,p2,n1,n2,mid)) r=mid;
               else l=mid+1;
          }
     cout<<fixed<<setprecision(6)<<r/1e7<<"\n";
     }
     return 0;
}

詳細信息

Test #1:

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

input:

2
10000.0 1.0 0.001 9999.0 0.001
4306.063 4079.874 0.607 1033.423 0.847

output:

5001000.000000
3827.837001

result:

ok 2 numbers

Test #2:

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

input:

1
10.0 1.0 10.0 9.0 0.1

output:

1.100000

result:

ok found '1.1000000', expected '1.1000000', error '0.0000000'

Test #3:

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

input:

1
10.0 8.0 10.0 9.0 0.1

output:

1.200000

result:

ok found '1.2000000', expected '1.2000000', error '0.0000000'

Test #4:

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

input:

1
10.0 8.0 0.1 9.0 10

output:

1.100000

result:

ok found '1.1000000', expected '1.1000000', error '0.0000000'

Test #5:

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

input:

1
10.0 2.0 0.1 3.0 10

output:

1.300000

result:

ok found '1.3000000', expected '1.3000000', error '0.0000000'

Test #6:

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

input:

1
10.0 9.0 0.1 8.0 10.0

output:

1.200000

result:

ok found '1.2000000', expected '1.2000000', error '0.0000000'

Test #7:

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

input:

1
10.0 4.0 0.1 6.0 0.1

output:

60.000000

result:

ok found '60.0000000', expected '60.0000000', error '0.0000000'

Test #8:

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

input:

1
10.0 4.5 0.1 6.0 0.1

output:

60.000000

result:

wrong answer 1st numbers differ - expected: '57.5000000', found: '60.0000000', error = '0.0434783'