Wrong Answer
Code
function countPerfectSquareSubgrids(H, W) {
let count = 0;
let maxSize = Math.min(H, W);
for (let size = 1; size <= maxSize; size++) {
let horizontalOptions = H - size + 1;
let verticalOptions = W - size + 1;
count += horizontalOptions * verticalOptions;
}
return count;
}
// Sample Input
const H = 5;
const W = 3;
console.log(countPerfectSquareSubgrids(H, W)); // Output: 26
Information
- Submit By
- Type
- Submission
- Problem
- P1121 Square Counting Challenge
- Contest
- Brain Booster #7
- Language
- JavaScript (Node.js v18.19.1)
- Submit At
- 2024-11-05 15:30:58
- Judged At
- 2024-11-05 15:30:58
- Judged By
- Score
- 10
- Total Time
- 121ms
- Peak Memory
- 13.883 MiB