H. Briefcase

Codeforces
IDCF10187H
Time2000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Tata and Tynati are still too young to understand exactly what their father works with, but they love playing with his briefcase. The briefcase has a combination lock composed of N wheels, and each wheel has all the digits (0 up to 9) engraved in it. The wheels can be rotated to display any combination of the N digits. Tata and Tynati tried to open the briefcase but they soon realized that it would take too much time to find out the right combination. So, instead of trying to open the briefcase, they decided to play a game with the combination lock. The rules of the game are the following: Tata plays first because she invented the game. Tata and Tynati already played this game hundreds of times, so both play optimally. Given the initial configuration of the game, can you tell who is going to win? The first line of the input contains a single integer N (1 ≤ N ≤ 100) indicating the number of wheels in the combination lock. The following line contains N integers indicating the digits of the initial configuration of the game from left to right. Output either TATA or TYNATI indicating the winner of the game knowing that both play optimally. ## Input The first line of the input contains a single integer N (1 ≤ N ≤ 100) indicating the number of wheels in the combination lock. The following line contains N integers indicating the digits of the initial configuration of the game from left to right. ## Output Output either TATA or TYNATI indicating the winner of the game knowing that both play optimally. [samples]
**Definitions** Let $ N, Q \in \mathbb{Z}^+ $. Let $ T = (t_1, t_2, \dots, t_N) $ be a sequence of integers representing daily temperatures. For each grapevine $ i \in \{1, \dots, Q\} $, let $ [\ell_i, r_i] $ denote the contiguous subsequence of days $ t_{\ell_i}, t_{\ell_i+1}, \dots, t_{r_i} $. Let $ f_i: \mathbb{Z} \to \mathbb{Z}^+ $ be the frequency function over the subsequence $ [\ell_i, r_i] $, where $ f_i(x) $ is the number of days temperature $ x $ appears. **Constraints** 1. $ 1 \leq N, Q \leq 10^5 $ 2. $ 1 \leq \ell_i \leq r_i \leq N $ for all $ i \in \{1, \dots, Q\} $ 3. Temperatures are integers in an arbitrary range. **Objective** For each grapevine $ i $, compute the maximum integer $ x \in \mathbb{Z}^+ $ such that there exist at least $ x $ distinct temperatures $ v_1, \dots, v_x $ with $ f_i(v_j) \geq x $ for all $ j \in \{1, \dots, x\} $. That is, $$ \text{quality}(i) = \max \left\{ x \in \mathbb{Z}^+ \,\middle|\, \left| \left\{ v \in \text{range}(f_i) \,\middle|\, f_i(v) \geq x \right\} \right| \geq x \right\} $$
API Response (JSON)
{
  "problem": {
    "name": "H. Briefcase",
    "description": {
      "content": "Tata and Tynati are still too young to understand exactly what their father works with, but they love playing with his briefcase. The briefcase has a combination lock composed of N wheels, and each wh",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10187H"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Tata and Tynati are still too young to understand exactly what their father works with, but they love playing with his briefcase. The briefcase has a combination lock composed of N wheels, and each wh...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ N, Q \\in \\mathbb{Z}^+ $.  \nLet $ T = (t_1, t_2, \\dots, t_N) $ be a sequence of integers representing daily temperatures.  \nFor each grapevine $ i \\in \\{1, \\dots, Q\\} $, let $ [...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments