QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#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;
}
详细
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'