QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#216797 | #2431. Getting a Jump on Crime | Swarthmore# | AC ✓ | 58ms | 3932kb | C++17 | 3.4kb | 2023-10-16 00:41:52 | 2023-10-16 00:41:53 |
Judging History
answer
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i, a, b) for (int i = (b) - 1; i >= (a); i--)
#define F0Rd(i, a) for (int i = (a) - 1; i >= 0; i--)
#define trav(a, x) for (auto &a : x)
#define sz(x) (int)(x).size()
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
const char nl = '\n';
const ld G = 9.80665;
const int INF = 1e8;
const ld eps = 1e-6;
void solve() {
int N, M;
ld W, V;
int rX, rY;
cin >> M >> N >> W >> V >> rY >> rX;
rY--; rX--;
ld H[N][M];
F0R(i, N) F0R(j, M) {
cin >> H[i][j];
}
int dist[N][M];
F0R(i, N) F0R(j, M) dist[i][j] = INF;
dist[rX][rY] = 0;
queue<pi> q; q.push({rX, rY});
while (!q.empty()) {
auto [x, y] = q.front(); q.pop();
F0R(a, N) {
F0R(b, M) {
if (a == x && b == y) continue;
if (dist[a][b] != INF) continue;
ld dis = sqrt((a-x)*(a-x)+(b-y)*(b-y)) * W;
ld distY = H[a][b] - H[x][y];
ld ang = atan(V*V / G / dis);
ld ti = dis / (V * cos(ang));
ld capY = ti * V * sin(ang) - ti * ti * G / 2;
if (capY <= distY) {
continue;
}
ld lo = ang;
ld hi = acos(-1)/2;
F0R(iter, 60) {
ld mid = (lo+hi)/2;
ld ti = dis / (V * cos(mid));
if (ti*V*sin(mid) - ti*ti*G / 2 > distY) {
lo = mid;
} else hi = mid;
}
ld co1 = H[x][y];
ld coSq = -G/2/V/V/cos(lo)/cos(lo) * dis * dis;
ld coX = tan(lo) * dis;
//cout << coSq << " " << coX << " " << co1 << nl;
int cx = x, cy = y;
int dx = (a - x) / abs(a-x);
int dy = (b-y) / abs(b-y);
vd posXC, posYC;
F0R(i, abs(a-x)) {
posXC.pb((i+0.5)/abs(a-x));
}
F0R(i, abs(b-y)) {
posYC.pb((i+0.5)/abs(b-y));
}
int px = 0, py = 0;
while (cx != a || cy != b) {
int sta = 2;
if (cx == a) {
sta = 1;
} else if (cy == b) {
sta = 0;
} else {
if (posXC[px] < posYC[py] - eps) {
sta = 0;
} else if (posYC[py] < posXC[px] - eps) {
sta = 1;
}
}
ld frac;
int nx, ny;
if (sta == 0) {
frac = posXC[px]; px++;
nx = cx + dx;
ny = cy;
} else if (sta == 1) {
frac = posYC[py]; py++;
ny = cy + dy;
nx = cx;
} else {
frac = posXC[px]; px++;
py++;
nx = cx + dx;
ny = cy + dy;
}
ld capH = 0;
FOR(i, min(nx, cx), max(nx, cx) + 1) {
FOR(j, min(ny, cy), max(ny, cy) + 1) {
capH = max(capH, H[i][j]);
}
}
/*cout << sta << " " << a << " " << b << " " << coX << " " << coY << nl;
cout << capH << " " << frac << " " << -frac*frac+coX*frac+coY << nl;*/
if (coSq * frac * frac + coX * frac + co1 < capH) {
goto done;
}
cx = nx; cy = ny;
//cout << x << " " << y << " " << a << " " << b << " " << cx << " " << cy << nl;
}
dist[a][b] = dist[x][y] + 1;
q.push({a, b});
done:
;
}
}
}
F0R(i, N) {
F0R(j, M) {
if (dist[i][j] == INF) {
cout << "X" << " ";
} else {
cout << dist[i][j] << " ";
}
}
cout << nl;
}
}
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
solve();
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 3724kb
Test #2:
score: 0
Accepted
time: 0ms
memory: 3724kb
Test #3:
score: 0
Accepted
time: 3ms
memory: 3736kb
Test #4:
score: 0
Accepted
time: 0ms
memory: 3900kb
Test #5:
score: 0
Accepted
time: 0ms
memory: 3932kb
Test #6:
score: 0
Accepted
time: 0ms
memory: 3720kb
Test #7:
score: 0
Accepted
time: 0ms
memory: 3684kb
Test #8:
score: 0
Accepted
time: 1ms
memory: 3696kb
Test #9:
score: 0
Accepted
time: 0ms
memory: 3672kb
Test #10:
score: 0
Accepted
time: 0ms
memory: 3932kb
Test #11:
score: 0
Accepted
time: 1ms
memory: 3832kb
Test #12:
score: 0
Accepted
time: 0ms
memory: 3924kb
Test #13:
score: 0
Accepted
time: 0ms
memory: 3696kb
Test #14:
score: 0
Accepted
time: 0ms
memory: 3924kb
Test #15:
score: 0
Accepted
time: 1ms
memory: 3796kb
Test #16:
score: 0
Accepted
time: 0ms
memory: 3904kb
Test #17:
score: 0
Accepted
time: 0ms
memory: 3696kb
Test #18:
score: 0
Accepted
time: 0ms
memory: 3696kb
Test #19:
score: 0
Accepted
time: 0ms
memory: 3720kb
Test #20:
score: 0
Accepted
time: 0ms
memory: 3720kb
Test #21:
score: 0
Accepted
time: 0ms
memory: 3724kb
Test #22:
score: 0
Accepted
time: 0ms
memory: 3888kb
Test #23:
score: 0
Accepted
time: 0ms
memory: 3676kb
Test #24:
score: 0
Accepted
time: 0ms
memory: 3672kb
Test #25:
score: 0
Accepted
time: 0ms
memory: 3676kb
Test #26:
score: 0
Accepted
time: 0ms
memory: 3720kb
Test #27:
score: 0
Accepted
time: 1ms
memory: 3660kb
Test #28:
score: 0
Accepted
time: 0ms
memory: 3700kb
Test #29:
score: 0
Accepted
time: 0ms
memory: 3700kb
Test #30:
score: 0
Accepted
time: 0ms
memory: 3696kb
Test #31:
score: 0
Accepted
time: 0ms
memory: 3700kb
Test #32:
score: 0
Accepted
time: 10ms
memory: 3728kb
Test #33:
score: 0
Accepted
time: 10ms
memory: 3700kb
Test #34:
score: 0
Accepted
time: 10ms
memory: 3740kb
Test #35:
score: 0
Accepted
time: 58ms
memory: 3672kb
Test #36:
score: 0
Accepted
time: 0ms
memory: 3724kb
Test #37:
score: 0
Accepted
time: 0ms
memory: 3904kb
Test #38:
score: 0
Accepted
time: 0ms
memory: 3920kb
Test #39:
score: 0
Accepted
time: 0ms
memory: 3892kb
Test #40:
score: 0
Accepted
time: 0ms
memory: 3760kb
Test #41:
score: 0
Accepted
time: 0ms
memory: 3884kb
Test #42:
score: 0
Accepted
time: 0ms
memory: 3900kb
Test #43:
score: 0
Accepted
time: 0ms
memory: 3888kb
Test #44:
score: 0
Accepted
time: 0ms
memory: 3672kb
Test #45:
score: 0
Accepted
time: 0ms
memory: 3724kb
Test #46:
score: 0
Accepted
time: 1ms
memory: 3728kb
Test #47:
score: 0
Accepted
time: 0ms
memory: 3728kb
Test #48:
score: 0
Accepted
time: 0ms
memory: 3760kb
Test #49:
score: 0
Accepted
time: 0ms
memory: 3768kb
Test #50:
score: 0
Accepted
time: 0ms
memory: 3764kb
Test #51:
score: 0
Accepted
time: 0ms
memory: 3724kb
Test #52:
score: 0
Accepted
time: 1ms
memory: 3888kb
Test #53:
score: 0
Accepted
time: 2ms
memory: 3736kb
Test #54:
score: 0
Accepted
time: 6ms
memory: 3724kb
Test #55:
score: 0
Accepted
time: 5ms
memory: 3932kb
Test #56:
score: 0
Accepted
time: 0ms
memory: 3768kb
Test #57:
score: 0
Accepted
time: 9ms
memory: 3896kb
Test #58:
score: 0
Accepted
time: 8ms
memory: 3796kb
Test #59:
score: 0
Accepted
time: 5ms
memory: 3768kb
Test #60:
score: 0
Accepted
time: 4ms
memory: 3908kb
Test #61:
score: 0
Accepted
time: 8ms
memory: 3724kb
Test #62:
score: 0
Accepted
time: 2ms
memory: 3792kb
Test #63:
score: 0
Accepted
time: 6ms
memory: 3724kb
Test #64:
score: 0
Accepted
time: 7ms
memory: 3732kb
Test #65:
score: 0
Accepted
time: 7ms
memory: 3900kb
Test #66:
score: 0
Accepted
time: 3ms
memory: 3704kb
Test #67:
score: 0
Accepted
time: 8ms
memory: 3728kb
Test #68:
score: 0
Accepted
time: 8ms
memory: 3728kb
Test #69:
score: 0
Accepted
time: 7ms
memory: 3736kb
Test #70:
score: 0
Accepted
time: 7ms
memory: 3684kb
Test #71:
score: 0
Accepted
time: 10ms
memory: 3712kb
Test #72:
score: 0
Accepted
time: 6ms
memory: 3704kb
Test #73:
score: 0
Accepted
time: 7ms
memory: 3736kb
Test #74:
score: 0
Accepted
time: 8ms
memory: 3732kb
Test #75:
score: 0
Accepted
time: 7ms
memory: 3676kb
Test #76:
score: 0
Accepted
time: 7ms
memory: 3828kb
Test #77:
score: 0
Accepted
time: 8ms
memory: 3924kb
Test #78:
score: 0
Accepted
time: 8ms
memory: 3728kb
Test #79:
score: 0
Accepted
time: 6ms
memory: 3704kb
Test #80:
score: 0
Accepted
time: 10ms
memory: 3700kb