QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#105101 | #5505. Great Chase | kingstonduy | Compile Error | / | / | C++14 | 1.8kb | 2023-05-12 23:05:16 | 2023-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]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [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';
}
}
詳細信息
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’