140. Continental Breakfast

Codeforces
IDCF10269140
Time1000ms
Memory256MB
Difficulty
English · Original
Formal · Original
You're eating at a continental breakfast in a hotel, and there are two menu options. Each menu option consists of several food items. You want to find how many food items are contained in both menus. The first line of input consists of a single positive integer $n 1$: the number of food items on the first menu. The second line of input consists of $n 1$ space-separated strings: the food items on the first menu. The third line of input consists of a single positive integer $n 2$: the number of food items on the second menu. The fourth line of input consists of $n 2$ space-separated strings: the food items on the second menu. Output a single positive integer $n$: the number of food items that are contained on both menus. Then, output $n$ lines: each food item which is contained on both menus, *in alphabetical order*. ## Input The first line of input consists of a single positive integer $n 1$: the number of food items on the first menu. The second line of input consists of $n 1$ space-separated strings: the food items on the first menu.The third line of input consists of a single positive integer $n 2$: the number of food items on the second menu. The fourth line of input consists of $n 2$ space-separated strings: the food items on the second menu. ## Output Output a single positive integer $n$: the number of food items that are contained on both menus. Then, output $n$ lines: each food item which is contained on both menus, *in alphabetical order*. [samples]
**Definitions** Let $ M_1 = \{s_{1,1}, s_{1,2}, \dots, s_{1,n_1}\} $ be the set of food items on the first menu. Let $ M_2 = \{s_{2,1}, s_{2,2}, \dots, s_{2,n_2}\} $ be the set of food items on the second menu. **Constraints** 1. $ n_1, n_2 \in \mathbb{Z}^+ $ 2. All $ s_{1,i}, s_{2,j} $ are strings. **Objective** Compute the intersection $ M = M_1 \cap M_2 $. Output: - $ |M| $, the cardinality of $ M $, - followed by the elements of $ M $ sorted in alphabetical order.
API Response (JSON)
{
  "problem": {
    "name": "140. Continental Breakfast",
    "description": {
      "content": "You're eating at a continental breakfast in a hotel, and there are two menu options. Each menu option consists of several food items. You want to find how many food items are contained in both menus. ",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10269140"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "You're eating at a continental breakfast in a hotel, and there are two menu options. Each menu option consists of several food items. You want to find how many food items are contained in both menus.\n...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ M_1 = \\{s_{1,1}, s_{1,2}, \\dots, s_{1,n_1}\\} $ be the set of food items on the first menu.  \nLet $ M_2 = \\{s_{2,1}, s_{2,2}, \\dots, s_{2,n_2}\\} $ be the set of food items on th...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments