G. Paradise City

Codeforces
IDCF10108G
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Noura has been looking for a restaurant to host the SCPC2015 celebration in Lattakia, she decided that the best method to pick a restaurant is according to the number of contestants that are living near it. Given a grid representing the map of Lattakia, each 3x3 cells represent a district, each district will consist of 3x3 areas. The center of each district is a restaurant (X), other cells can be: The first line of input contains an integer T (1 ≤ T ≤ 256), the number of test cases. The first line of each test case contains an integer N (1 ≤ N ≤ 100), the number of districts. Then follows three lines, each consists of 3 × N characters, representing the map of the city of N districts. For each test case, print the maximum number of students living in a district on a single line. Warning: large Input/Output data, be careful with certain languages. ## Input The first line of input contains an integer T (1 ≤ T ≤ 256), the number of test cases.The first line of each test case contains an integer N (1 ≤ N ≤ 100), the number of districts. Then follows three lines, each consists of 3 × N characters, representing the map of the city of N districts. ## Output For each test case, print the maximum number of students living in a district on a single line. [samples] ## Note Warning: large Input/Output data, be careful with certain languages.
**Definitions** Let $ T \in \mathbb{Z} $ be the number of test cases. For each test case $ k \in \{1, \dots, T\} $: - Let $ N_k \in \mathbb{Z} $ denote the number of districts. - Let $ M_k \in \{ \text{char} \}^{3 \times (3N_k)} $ be a grid representing the city map, with 3 rows and $ 3N_k $ columns. - Each district corresponds to a contiguous $ 3 \times 3 $ block in $ M_k $, indexed by $ j \in \{1, \dots, N_k\} $, where the center cell of district $ j $ is at position $ (2, 3j - 1) $. - Each cell in $ M_k $ contains either: - `'X'`: denotes the restaurant (center of district), - `'S'`: denotes a student living in that area, - `'.'`: empty space. **Constraints** 1. $ 1 \le T \le 256 $ 2. For each $ k \in \{1, \dots, T\} $: - $ 1 \le N_k \le 100 $ - $ M_k $ has exactly 3 rows and $ 3N_k $ columns **Objective** For each test case $ k $, compute: $$ \max_{j=1}^{N_k} \left( \sum_{\substack{r=1,2,3 \\ c=3j-2,3j-1,3j}} \mathbf{1}_{M_k[r][c] = 'S'} \right) $$ Output this maximum value.
API Response (JSON)
{
  "problem": {
    "name": "G. Paradise City",
    "description": {
      "content": "Noura has been looking for a restaurant to host the SCPC2015 celebration in Lattakia, she decided that the best method to pick a restaurant is according to the number of contestants that are living ne",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10108G"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Noura has been looking for a restaurant to host the SCPC2015 celebration in Lattakia, she decided that the best method to pick a restaurant is according to the number of contestants that are living ne...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ T \\in \\mathbb{Z} $ be the number of test cases.  \nFor each test case $ k \\in \\{1, \\dots, T\\} $:  \n- Let $ N_k \\in \\mathbb{Z} $ denote the number of districts.  \n- Let $ M_k \\in...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments