# Problem Description
This is a grid infection spread simulation problem. Given an n×n grid with an initial infection point, we need to calculate how many cells will be infected after t days. The infection spreads following a specific diagonal pattern, unlike traditional adjacent cell spreading.

# Visual Facts
1. The image shows a 6×6 grid over 4 days of infection spread
2. Initial infection point is at coordinate (3, 5) on Day 1
3. White squares represent healthy cells
4. Blue squares represent infected cells
5. Grid coordinates are labeled from 1 to 6 for both rows and columns
6. The number of infected cells per day:
   - Day 1: 1 cell
   - Day 2: 5 cells
   - Day 3: 10 cells
   - Day 4: 15 cells

# Visual Patterns
1. Infection Spread Pattern:
   - Each infected cell spreads to its four diagonally adjacent cells (top-right, top-left, bottom-left, bottom-right) the next day
   - Already infected cells remain infected
   - Cells can't spread infection beyond grid boundaries (if n=6, the coordinates of cells are 1 to 6)

2. Mathematical Patterns:
   - At day 1, there is only 1 infected cell
   - At day 2, the 1 infected cell spreads to 4 new cells (total 5)
   - At day 3, the 5 infected cells spread to 5 new cells (total 10)
   - At day 4, the 10 infected cells spread to 5 new cells (total 15)

# Solution
from typing import Tuple

def solution(n: int, initial_point: Tuple[int, int], t: int) -> int:
    """
    Calculate the number of infected cells after t days.

    Input:
    - n: An integer representing the size of the grid (n x n).
    - initial_point: A tuple (x, y) representing the coordinates of the initial infection point. (1-indexed)
    - t: An integer representing the elapsed time in days.

    Output:
    - An integer representing the total number of infected cells after t days.
    """
    # Initialize the grid
    grid = [[0] * n for _ in range(n)]

    # Convert initial_point to 0-indexed
    x, y = initial_point[0] - 1, initial_point[1] - 1

    # Set the initial infection point
    grid[x][y] = 1

    # Directions for up, down, left, right
    directions = [(-1, -1), (-1, 1), (1, -1), (1, 1)]

    # Iterate for each day
    for day in range(t):
        new_infections = []
        for i in range(n):
            for j in range(n):
                if grid[i][j] != 1:
                    continue
                # Spread the infection to adjacent cells
                for dx, dy in directions:
                    ni, nj = i + dx, j + dy
                    if 0 <= ni < n and 0 <= nj < n and grid[ni][nj] == 0:
                        new_infections.append((ni, nj))

        # Mark new infections
        for ni, nj in new_infections:
            grid[ni][nj] = 1

    # Count the number of infected cells
    infected_cells = sum(sum(row) for row in grid)

    return infected_cells


# Test Script

def test():
    test_cases = [
        (6, (3, 5), 0, 1),
        (6, (3, 5), 2, 10),
        (6, (3, 5), 3, 15),
        (9, (3, 8), 2, 10),
        (3, (2, 2), 2, 5),
        (6, (1, 6), 5, 18),
        (6, (1, 6), 6, 18),
        (6, (6, 3), 3, 12),
        (6, (6, 3), 4, 15),
    ]
    for n, initial_point, t, expected_output in test_cases:
        try:
            output = solution(n, initial_point, t)
        except Exception as e:
            error_message = (
                f"An exception occurred while running the test case:\n"
                f"`n`: {n}\n"
                f"`initial_point`: {initial_point}\n"
                f"`t`: {t}\n\n"
                f"Exception: '{str(e)}'"
            )
            assert False, error_message

        if output != expected_output:
            error_message = (
                f"The following Test Case failed:\n"
                f"`n`: {n}\n"
                f"`initial_point`: {initial_point}\n" 
                f"`t`: {t}\n\n"
                f"Actual Output: {output}\n"
                f"Expected Output: {expected_output}"
            )
            assert False, error_message

test()