版本比较
总结示例
正文
增加 7 行删除 7 行
27 行未改动282930313232333435367 行未改动44454647484849505151525354555556575859596061626162636465668 行未改动27 行未改动};
int dfs(int x, int y) { int res = 0;
for (int i=0; i<4; i++) { int nx = x+d[i][0], ny = y+d[i][1]; if (nx < 1 or nx > n or ny < 1 or ny > m or mp[x][y] <= mp[nx][ny]) continue; // 这里取每个分支的最值,而不是取总和。7 行未改动 qwq; cin >> n >> m; for (int i=1; i<=n; i++) for (int j=1; j<=m; j++) cin >> mp[i][j];
int maxx = 0, x, y; // 枚举每个点作为起点 for (int i=1; i<=n; i++) for (int i=1; i<=n; i++) for (int j=1; j<=m; j++){ // 记录最大值,以及最大值对应的起点 int t = dfs(i, j);
if (maxx < t) { maxx = t; x = i, y = j; } } } cout << x << " " << y << endl << maxx;
cout << x << " " << y << endl << maxx; return 0;}```
8 行未改动