QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#637355#9224. Express Evictionucup-team3646#WA 0ms3792kbC++20769b2024-10-13 12:20:072024-10-13 12:20:07

Judging History

你现在查看的是最新测评结果

  • [2024-10-13 12:20:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3792kb
  • [2024-10-13 12:20:07]
  • 提交

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'