?
# | Author | Problem | Lang | Verdict | Time | Memory | Sent | Judged | |
---|---|---|---|---|---|---|---|---|---|
268558565 |
Practice: keerthi23bcd10 |
1986B - 15 | C++14 (GCC 6-32) | Wrong answer on test 3 | 1015 ms | 424 KB | 2024-07-03 07:51:11 | 2024-07-03 07:51:11 |
#include <iostream> #include <vector> #include <algorithm> using namespace std; typedef long double ld; typedef long long ll; void solve(vector<vector<ld>> &matrix, int i, int j) { ld max_val = max({matrix[i-1][j], matrix[i+1][j], matrix[i][j-1], matrix[i][j+1]}); matrix[i][j] = max_val; } int main() { ll T; cin >> T; while (T--) { int n, m; cin >> n >> m; vector<vector<ld>> matrix(n + 2, vector<ld>(m + 2, 0)); // Added padding to avoid boundary check for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { cin >> matrix[i][j]; } } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { ld a = matrix[i+1][j]; ld b = matrix[i-1][j]; ld c = matrix[i][j+1]; ld d = matrix[i][j-1]; ld e = matrix[i][j]; if (e > a && e > b && e > c && e > d) { solve(matrix, i, j); } } } for (int i = 1; i <= n; ++i) { for (int j = 1; j <= m; ++j) { cout << matrix[i][j] << " "; } cout << endl; } } return 0; }
?
?
?
?