QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#828339 | #8774. Manhattan Walk | suo | WA | 0ms | 3772kb | C++20 | 753b | 2024-12-23 16:01:23 | 2024-12-23 16:01:32 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
int main() {
int r, c;
double p;
cin >> r >> c >> p;
double dp[r][c];
dp[r - 1][c - 1] = 0;
for (int i = r - 1; i >= 0; i--) {
for (int j = c - 1; j >= 0; j--) {
if (i == r - 1 && j == c - 1) continue;
double di = (i == r - 1) ? (1 << 30) : dp[i + 1][j];
double dj = (j == c - 1) ? (1 << 30) : dp[i][j + 1];
double t = min(p, max((double)0, dj - di));
double ans = t * t / 2 + t * di + (p - t) * dj;
t = min(p, max((double)0, di - dj));
ans += t * t / 2 + t * dj + (p - t) * di;
dp[i][j] = ans / 2 / p;
}
}
cout << dp[0][0] << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3772kb
input:
2 3 8
output:
2.875
result:
ok found '2.8750000', expected '2.8750000', error '0.0000000'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3744kb
input:
5 5 5
output:
2.43223
result:
wrong answer 1st numbers differ - expected: '2.4322339', found: '2.4322300', error = '0.0000016'