QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#768845#8022. Walkersurenjamts#Compile Error//C++202.2kb2024-11-21 14:50:502024-11-21 14:50:51

Judging History

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

  • [2024-11-21 14:50:51]
  • 评测
  • [2024-11-21 14:50:50]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mk make_pair
#define S second
#define F first

void solve(){
   double n;
   cin >> n;
   double p1, p2, v1, v2;
   cin >> p1 >> v1 >> p2 >> v2;
   if(p1 > p2) swap(p1, p2), swap(v1, v2);
   double ans = (n + min(p1 , n - p)) / v1;
   ans = min(ans, (n + min(p2, n - p2))/ v2);
   ans = min(ans, max(p2 / v2 , (n - p1) / v2));
   ans = min(ans, (2 * n - abs(p2 - p1)) / (v1 + v2));
   ans = min(ans, max(p1 / v1 , (n - p1 + n - p2) / v2));
   ans = min(ans, max((n - p2) / v2, (p1 + p2) / v1));


    auto check = [&](double mid){
           double l1 = mid * v1, l2 = mid * v2;
           if(l1 >= n + p1) return 1;
           if(l2 >= 2 * n - p2) return 1;


           if(l1 >= p1 && l2 >= (n - p2) * 2){
                 double x1 = (l1 - p1) / 2;
                 double x2 = (l2 - 2 * (n - p2));
                 if(p1 + x1 > p2 - x2) return 1;
           }
           if(l1 >= p1 * 2 && l2 >= (n - p2)){
                 double x1 = (l1 - p1 * 2);
                 double x2 = (l2 - (n - p2)) / 2;
                 if(p1 + x1 > p2 - x2) return 1;
           }
           if(l1 >= p1 * 2 && l2 >= (n - p2) * 2){
                 double x1 = (l1 - p1 * 2);
                 double x2 = (l2 - (n - p2) * 2);
                 if(p1 + x1 > p2 - x2) return 1;

           }
           if(l1 >= p1 && l2 >= (n - p2)){
                 double x1 = (l1 - p1) /2;
                 double x2 = (l2 - (n - p2)) / 2;
                 if(p1 + x1 > p2 - x2) return 1;
           }


           if(l1 >= p1 && l2 >= 2 * n - p1 - p2) return 1;
           if(l2 >= (n - p2) && l1 >= p1 * p2) return 1;

           if(l1 >= (n - p1) && l2 >= p2) return 1;
           return 0;
    };

    double l = 0, r = 1e9;
    for(int i = 0; i < 200; i++){
          double mid = (l + r)/2;
          if(check(mid)) r = mid;
          else l = mid;
    }


    cout << min(ans, l) << endl;








   cout << setprecision(18) << ans << '\n';
}
int main(){
    ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
	  int t;  cin >> t; while(t--) solve();
}

Details

answer.code: In function ‘void solve()’:
answer.code:15:35: error: ‘p’ was not declared in this scope; did you mean ‘p2’?
   15 |    double ans = (n + min(p1 , n - p)) / v1;
      |                                   ^
      |                                   p2