QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#637038 | #8774. Manhattan Walk | Tenshi# | WA | 0ms | 3908kb | C++23 | 1.3kb | 2024-10-13 06:37:40 | 2024-10-13 06:37:40 |
Judging History
answer
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ld long double
int main() {
long long r, c; cin >> r >> c;
ld p; cin >> p;
ld ans[r][c];
ld p4 = p*(ld)4;
rep (ii, r) {
rep (jj, c) {
int i = r-ii-1;
int j = c-jj-1;
// cout << i << ' ' << j << endl;
if (i==r-1 and j==c-1) {
ans[i][j] = 0;
}
else if (i==r-1) {
ans[i][j] = ans[i][j+1] + p/(ld)4;
}
else if (j==c-1) {
ans[i][j] = ans[i+1][j] + p/(ld)4;
}
else {
ld mn = ans[i+1][j];
ld mx = ans[i+1][j];
if (ans[i+1][j] < ans[i][j+1]) {
mx = ans[i][j+1];
}
else {
mn = ans[i][j+1];
}
ld d = mx-mn;
ans[i][j] = mn/2.0 + mx/2.0 - (mn/p4)*d;
}
assert(ans[i][j] > -0.5);
}
}
// rep(i, r) {
// rep(j, c) {
// cout << ans[i][j] << ' ';
// }
// cout << endl << endl;
// }
cout << fixed << setprecision(10) << ans[0][0] << endl;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3908kb
input:
2 3 8
output:
2.8750000000
result:
ok found '2.8750000', expected '2.8750000', error '0.0000000'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3900kb
input:
5 5 5
output:
2.3365097147
result:
wrong answer 1st numbers differ - expected: '2.4322339', found: '2.3365097', error = '0.0393565'