QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#637355 | #9224. Express Eviction | ucup-team3646# | WA | 0ms | 3792kb | C++20 | 769b | 2024-10-13 12:20:07 | 2024-10-13 12:20:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T>
bool chmin(T &a, const T &b) {if (a > b) {a = b; return 1;} return 0;}
void solve() {
ll H, W; cin >> H >> W;
vector<vector<ll>> b(H, vector<ll>(W, 0));
for (ll i = 0; i < H; ++i) {
string S; cin >> S;
for (ll j = 0; j < W; ++j) {
if (S[j] == '#') b[i][j] = 1;
}
}
vector<vector<ll>> dp(H, vector<ll>(W, 1e9));
dp[0][0] = 0;
for (ll i = 0; i < H; ++i) {
for (ll j = 0; j < W; ++j) {
if (i > 0) chmin(dp[i][j], dp[i-1][j]);
if (j > 0) chmin(dp[i][j], dp[i][j-1]);
if (b[i][j]) dp[i][j] += 1;
}
}
cout << dp[H-1][W-1] << endl;
return;
}
int main() {
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3628kb
input:
4 6 .##... .#.... ##.... ....#.
output:
1
result:
ok 1 number(s): "1"
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3792kb
input:
20 30 ...########################### #..########################### ...########################### ...########################### .############################# ...########################### ...########################### #..########################### ...########################### ..#...............
output:
9
result:
wrong answer 1st numbers differ - expected: '11', found: '9'