B. Wet Shark and Coordinate Plane Game

Codeforces
IDCF10160B
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Wet Shark is now trying to help Dry Shark cheat in a game so that Dry Shark can win. The game is played on a regular xy coordinate grid. There is a stack of n cards. Wet Shark will hand all n cards to Dry Shark, in some order. When Dry Shark receives a card, he must move in the direction stated by the card. In the game, there are 2 types of cards, as follows: Type 1 cards are in the form “Right X, Left Y.” This means that Wet Shark must move right X units and then move left Y units, in that order. Type 2 cards are in the form “Up X, Down Y.” This means that Wet Shark must move up X units and then move down Y units, in that order. Dry Shark initially starts on the point (1, 1). If Wet Shark ever crosses or lands on the x or y axis after he is handed any card, he becomes consumed by the Evil Sharks, and therefore loses the game. If Wet Shark can hand Dry Shark the cards in some order so that he never gets consumed by the Evil Sharks, Dry Shark wins the game. Determine if there is a way Wet Shark can hand Dry Shark the cards so that Dry Shark can win the game. The Evil Sharks, however, still want to eat Dry Shark in the game. Therefore, help the Evil Sharks determine what point Dry Shark will land on if he wins. The first line contains an integer n (1 ≤ n ≤ 1000). Each of the next n lines contains 3 space-separated integers ti, Xi, Yi (1 ≤ ti ≤ 2,  - 1000 ≤ Xi, Yi ≤ 1000), representing the type and values written on the ith card. If ti = 1, a Type 1 card is depicted; X and Y are the units Dry Shark is to move right and left, respectively. If ti = 2, a Type 2 card is depicted; X and Y are the units Dry Shark is to move up and down, respectively. On the first line of the output, output a single "YES" or "NO" (quotes for clarity). Output "YES" if Dry Shark can win and "NO" if Dry Shark cannot win. If Dry Shark can win, output the coordinates of the point Wet Shark will be at after Wet Shark gives him all the cards. Check the sample output for the exact format. Note that the Xi, Yi could be negative. Going right  - n blocks is equivalent to going left n blocks, and going up  - m blocks is equivalent to going down m blocks. ## Input The first line contains an integer n (1 ≤ n ≤ 1000).Each of the next n lines contains 3 space-separated integers ti, Xi, Yi (1 ≤ ti ≤ 2,  - 1000 ≤ Xi, Yi ≤ 1000), representing the type and values written on the ith card. If ti = 1, a Type 1 card is depicted; X and Y are the units Dry Shark is to move right and left, respectively. If ti = 2, a Type 2 card is depicted; X and Y are the units Dry Shark is to move up and down, respectively. ## Output On the first line of the output, output a single "YES" or "NO" (quotes for clarity). Output "YES" if Dry Shark can win and "NO" if Dry Shark cannot win.If Dry Shark can win, output the coordinates of the point Wet Shark will be at after Wet Shark gives him all the cards. Check the sample output for the exact format. [samples] ## Note Note that the Xi, Yi could be negative. Going right  - n blocks is equivalent to going left n blocks, and going up  - m blocks is equivalent to going down m blocks.
**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 coders. - Let $ R_k = (r_{k,1}, r_{k,2}, \dots, r_{k,n_k}) $ be a sequence of integers representing the ratings of the coders. **Constraints** 1. $ 1 \le T \le 512 $ 2. For each $ k \in \{1, \dots, T\} $: - $ 1 \le n_k \le 500 $ - $ 1 \le r_{k,i} \le 4000 $ for all $ i \in \{1, \dots, n_k\} $ 3. $ \sum_{k=1}^{T} n_k \le 1.5 \times 10^5 $ **Objective** Form the maximum number of disjoint teams, each of size exactly 6, such that for every team, the absolute difference between the maximum and minimum rating of its members is at most 1000. Each coder may belong to at most one team. Let $ \mathcal{F} $ be the family of all possible 6-element subsets $ S \subseteq R_k $ such that $ \max(S) - \min(S) \le 1000 $. Maximize $ |\mathcal{M}| $, where $ \mathcal{M} \subseteq \mathcal{F} $ is a collection of pairwise disjoint subsets.
API Response (JSON)
{
  "problem": {
    "name": "B. Wet Shark and Coordinate Plane Game",
    "description": {
      "content": "Wet Shark is now trying to help Dry Shark cheat in a game so that Dry Shark can win. The game is played on a regular xy coordinate grid. There is a stack of n cards. Wet Shark will hand all n cards to",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10160B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Wet Shark is now trying to help Dry Shark cheat in a game so that Dry Shark can win. The game is played on a regular xy coordinate grid. There is a stack of n cards. Wet Shark will hand all n cards to...",
      "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 coders.  \n- Let $ R_k = (r_{...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments