QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#105104#5505. Great ChasekingstonduyCompile Error//C++141.9kb2023-05-12 23:07:162023-05-12 23:07:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-12 23:07:19]
  • 评测
  • [2023-05-12 23:07:16]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define all(x) begin(x), end(x)
#define int long long
#define sz(x) (int)(x).size()

typedef pair<int, int> pii;
typedef vector<int> vi;


const int inf = (int)1e18;

long doubleupdatePos(long double t, vector<pair<int, long double>>& cops, int flag) {
    long double pos = DBL_MAX;
    for (auto& i : cops) {
        if (pos > (i.second + i.first * t) * flag) {
            pos = (i.second + i.first * t) * flag;
        }
    }

    return pos;
}


long double BinSearch(long double l, long double r, vector<pair<int, long double >>& pos, vector<pair<int, long double >>& neg) {
    long double mid;
    int cnt= 100;

    while (cnt-- && r - l > 1e-12 ) {
        mid = (l + r) / 2.0;
        long double posL = -1 * updatePos(mid, neg, -1);
        long double posR = updatePos(mid, pos, 1);
        if (posR - posL < 0) {
            r = mid ;
        } else {
            l = mid;
        }
    }
    return mid;
}



signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    cin.exceptions(std::istream::failbit);
    // freopen("../input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);


    int t;
    cin >> t;
    while (t--) {
        int n, v;
        cin >> n >> v;
        vector<pair<int, long double >> pos;
        vector<pair<int, long double >> neg;
        long double p;
        int vel;
        long double dis = 0;
        for (int i = 0; i < n; i++) {

            cin >> p >> vel;
            dis = max(dis, abs(p));
            if (p > 0) {
                pos.push_back({ -vel, p });
            } else {
                neg.push_back({ vel, p });
            }
        }

        p = 0;

        long double t = BinSearch(0, dis, pos, neg);


        cout << fixed << setprecision(10) << t * v << '\n';

    }


}

详细

answer.code: In function ‘long double BinSearch(long double, long double, std::vector<std::pair<long long int, long double> >&, std::vector<std::pair<long long int, long double> >&)’:
answer.code:33:33: error: ‘updatePos’ was not declared in this scope
   33 |         long double posL = -1 * updatePos(mid, neg, -1);
      |                                 ^~~~~~~~~