QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#124909 | #5648. Crossing the Railways | Hongzy# | Compile Error | / | / | C++17 | 4.3kb | 2023-07-15 18:29:50 | 2023-07-15 18:29:51 |
Judging History
你现在查看的是最新测评结果
- [2023-08-10 23:21:45]
- System Update: QOJ starts to keep a history of the judgings of all the submissions.
- [2023-07-15 18:29:51]
- 评测
- 测评结果:Compile Error
- 用时:0ms
- 内存:0kb
- [2023-07-15 18:29:50]
- 提交
answer
#include <bits/stdc++.h>
#define LOG(FMT...) fprintf(stderr, FMT);
#define rep(i, j, k) for(int i = j; i <= k; ++ i)
#define per(i, j, k) for(int i = j; i >= k; -- i)
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
using db = double;
using ll = long long;
using uint = unsigned int;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
mt19937 mt(chrono::system_clock::now().time_since_epoch().count());
uniform_int_distribution<ll> ran(0, 1ll << 62);
void ucin() { ios::sync_with_stdio(0); cin.tie(0); }
// uniform_real_distribution<double> dbran;
template<class T> inline void chkmax(T &x, const T &y) { if(x < y) x = y; }
template<class T> inline void chkmin(T &x, const T &y) { if(x > y) x = y; }
inline ll sqr(ll x) { return x * x; }
inline ll cub(ll x) { return x * x * x; }
const int N = 510;
const int INF = 1e9;
const db eps = 1e-5;
#define lt(x, y) ((x) < (y) - eps)
#define leq(x, y) ((x) < (y) + eps)
struct seg {
int r, a, b;
bool operator < (const seg &rhs) const {
if(r != rhs.r) return r < rhs.r;
return a < rhs.a;
}
} a[N];
int n, m, s, v;
int dp[N*2], X[N*2], Y[N*2];
bool inc(db l, db x, db r) {
return lt(l, x) && lt(x, r);
}
bool inc(db x1, int y1, db x2, int y2) {
// assert(lt(x1, x2) && y1 < y2);
rep(i, 1, n)
if(y1 <= a[i].r && a[i].r <= y2) {
db k = (x2 - x1) / (y2 - y1);
db x0 = k * a[i].r + x1 - k * y1;
if(inc(a[i].a, x0, a[i].b))
return true;
}
return false;
}
int main() {
scanf("%d%d%d%d", &n, &m, &s, &v);
rep(i, 1, n) {
int a, b, r;
scanf("%d%d%d", &a, &b, &r);
::a[i] = {r, a, b};
}
sort(a + 1, a + n + 1);
{
db x0 = 0, x2 = (m + 1.0) * v;
if(!inc(x0, 0, x2, m + 1) && leq(x2, s)) {
puts("0");
// cerr << "**\n";
return 0;
}
}
dp[0] = 0;
rep(i, 1, 2*n) {
int y = a[(i + 1) / 2].r;
int x = i & 1 ? a[(i + 1) / 2].a : a[(i + 1) / 2].b;
X[i] = x, Y[i] = y;
// printf("(%d, %d)\n", x, y);
}
//single point rush
rep(i, 1, 2*n) {
db x = X[i];
int y = Y[i];
db x2 = x + (m + 1.0 - y) * v;
db x0 = x - (db)y * v;
if(leq(0, x0) && leq(x2, s) && !inc(x0, 0, x2, m + 1)) {
puts("0");
// cerr << "()\n";
return 0;
}
}
rep(i, 1, 2*n)
rep(j, i+1, 2*n)
if(X[i] < X[j] && Y[i] < Y[j] && (Y[j] - Y[i]) * v <= (X[j] - X[i])) {
// printf("(%d, %d)!\n", i, j);
db k = (Y[j] - Y[i]) / db(X[j] - X[i]);
db x0 = X[i] - Y[i] / k, x2 = X[j] + (m + 1 - Y[j]) / k;
if(leq(0, x0) && leq(x2, s) && !inc(x0, 0, x2, m + 1)) {
puts("0");
// cerr << "[]\n";
return 0;
}
}
int ans = INF;
rep(i, 1, 2*n) {
int x = X[i], y = Y[i];
dp[i] = INF;
db x0 = x - (db)y * v;
if(leq(0, x0) && !inc(x0, 0, x, y)) {
// printf("x0 = %.1f\n", x0);
dp[i] = 0;
} else {
rep(j, 1, i-1) {
if(x > X[j] && y > Y[j] && (y - Y[j]) * v <= (x - X[j])) {
db v0 = (y - Y[j]) / db(x - X[j]);
db x0 = x - (db)y / v0;
if(leq(0, x0) && !inc(x0, 0, x, y)) {
dp[i] = 0;
break;
}
}
}
}
if(dp[i] == INF) {
rep(j, 1, i-1)
if(dp[j] + 1 < dp[i] && x > X[j] && y > Y[j] && (y - Y[j]) * v <= (x - X[j])) {
// printf("(%d -> %d\n", i, j);
if(!inc(X[j], Y[j], x, y)) {
// printf("%d -> %d\n", i, j);
dp[i] = dp[j] + 1;
}
}
}
// printf("dp %d = %d\n", i, dp[i]);
if(dp[i] < INF) {
db x2 = x + (m + 1 - y) * v;
if(leq(x2, s) && !inc(x, y, x2, m + 1)) {
// printf("%d -> end\n", i);
ans = min(ans, dp[i] + 1);
} else {
rep(j, i+1, 2*n) {6
if(x < X[j] && y < Y[j] && (Y[j] - y) * v <= (X[j] - x)) {
db v0 = (Y[j] - y) / db(X[j] - x);
db x2 = x + (db)(m + 1 - y) / v0;
if(leq(x2, s) && !inc(x, y, x2, m + 1)) {
// printf("%d -> end\n", i);
ans = min(ans, dp[i] + 1);
break;
}
}
}
}
}
}
if(ans == INF) ans = -1;
printf("%d\n", ans);
return 0;
}
详细
answer.code: In function ‘int main()’: answer.code:146:28: error: expected ‘;’ before ‘if’ 146 | rep(j, i+1, 2*n) {6 | ^ | ; 147 | if(x < X[j] && y < Y[j] && (Y[j] - y) * v <= (X[j] - x)) { | ~~ answer.code:59:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 59 | scanf("%d%d%d%d", &n, &m, &s, &v); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~ answer.code:62:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 62 | scanf("%d%d%d", &a, &b, &r); | ~~~~~^~~~~~~~~~~~~~~~~~~~~~