QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#105101#5505. Great ChasekingstonduyCompile Error//C++141.8kb2023-05-12 23:05:162023-05-12 23:05:17

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:05:17]
  • 评测
  • [2023-05-12 23:05:16]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

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

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


const int inf = (int)1e18;

double updatePos(double t, vector<pair<int, double>>& cops, int flag) {
    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;
}


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

    while (cnt-- && r - l > 1e-12 ) {
        mid = (l + r) / 2.0;
        double posL = -1 * updatePos(mid, neg, -1);
        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, double>> pos;
        vector<pair<int, double>> neg;
        double p;
        int vel;
        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;

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


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

    }


}

Details

answer.code: In function ‘long double updatePos(long double, std::vector<std::pair<long long int, long double> >&, long long int)’:
answer.code:7:16: error: expected primary-expression before ‘long’
    7 | #define double long double
      |                ^~~~
<built-in>: note: in expansion of macro ‘double’