### Problem
Land cells equal one and connect only through shared edges. Two islands have the same shape exactly when translating one set of cells makes it equal the other; rotations and reflections do not count as equivalent. Return the number of distinct island shapes.
```cpp
class Solution {
public:
int numDistinctIslands(vector<vector<int>>& grid);
};
```
### Examples
**Example 1:**
```text
grid = [[1,1,0,1,1],[1,0,0,1,0]]
Output: 1
Explanation: The two L shapes differ only by translation.
```
**Example 2:**
```text
grid = [[1,1,0,0],[0,0,0,1],[0,0,0,1]]
Output: 2
Explanation: Horizontal and vertical two-cell islands are rotations, not translations.
```
### Constraints
- The binary grid has m rows and n columns, each dimension in 1..50; every row contains n entries.
### Clarifying Questions
Normalize translation without normalizing rotation or reflection, and keep four-direction connectivity.
```hint Read the boundary condition
What coordinate offset cancels an island's absolute location while keeping its orientation?
```
### Contract considerations
Normalize translation without normalizing rotation or reflection, and keep four-direction connectivity.
Overview: Count Island Shapes up to Translation Only. Land cells equal one and connect only through shared edges.
Land cells equal one and connect only through shared edges. Two islands have the same shape exactly when translating one set of cells makes it equal the other; rotations and reflections do not count as equivalent. Return the number of distinct island shapes.
class Solution {
public:
int numDistinctIslands(vector<vector<int>>& grid);
};
Examples
Example 1:
grid = [[1,1,0,1,1],[1,0,0,1,0]]
Output: 1
Explanation: The two L shapes differ only by translation.
Example 2:
grid = [[1,1,0,0],[0,0,0,1],[0,0,0,1]]
Output: 2
Explanation: Horizontal and vertical two-cell islands are rotations, not translations.
Constraints
The binary grid has m rows and n columns, each dimension in 1..50; every row contains n entries.
Clarifying Questions Guidance
Normalize translation without normalizing rotation or reflection, and keep four-direction connectivity.
Contract considerations
Normalize translation without normalizing rotation or reflection, and keep four-direction connectivity.