G. I love Codeforces

Codeforces
IDCF10134G
Time2000ms
Memory256MB
Difficulty
English · Original
Formal · Original
Among participants of programming contests at codeforces.com the following tradition is common: whenever a participant falls in love with another participant, he changes his nickname to «_I_love__». Unfortunately, for technical reasons site administration has lost the current nicknames of participants who had changed their nicknames recently, but the information about who of them fell in love with whom remains. Now the administration needs to write a program for determining the current nickname of the given participant. It should be noted that due to the small bug in the database structure different participants can have the same nicknames on this site. The first line contains a single integer n (2 ≤ n ≤ 200000) — the number of participants. In the next n lines initial nicknames of participants are given. Each nickname is a non-empty string of length at most 24 characters, consisting only of uppercase and lowercase Latin letters and also underscores. Some nicknames can coincide. The next line contains a single integer m (1 ≤ m ≤ 200000) — the number of records that one of the participants fell in love with another participant. In the next m lines pairs of integers aj and bj, separated by a space, are given (1 ≤ aj, bj ≤ n, aj ≠ bj) — a record that the aj-th participant fell in love with the bj-th participant and changed his nickname correspondingly. Participants are numbered from one in the order their initial nicknames are given. Renamings occur in the order they are given. In the only line output the final nickname of the first participant after all renamings. ## Input The first line contains a single integer n (2 ≤ n ≤ 200000) — the number of participants.In the next n lines initial nicknames of participants are given. Each nickname is a non-empty string of length at most 24 characters, consisting only of uppercase and lowercase Latin letters and also underscores. Some nicknames can coincide.The next line contains a single integer m (1 ≤ m ≤ 200000) — the number of records that one of the participants fell in love with another participant.In the next m lines pairs of integers aj and bj, separated by a space, are given (1 ≤ aj, bj ≤ n, aj ≠ bj) — a record that the aj-th participant fell in love with the bj-th participant and changed his nickname correspondingly. Participants are numbered from one in the order their initial nicknames are given. Renamings occur in the order they are given. ## Output In the only line output the final nickname of the first participant after all renamings. [samples]
**Definitions** Let $ n \in \mathbb{Z}^+ $ be the number of supervisors. Let $ m \in \mathbb{Z}^+ $ be the number of graduation project groups. **Constraints** $ 1 \leq n, m \leq 10^3 $ **Objective** Determine whether $ n \mid m $, i.e., whether $ m $ is divisible by $ n $. If yes, output "YES"; otherwise, output "NO".
API Response (JSON)
{
  "problem": {
    "name": "G. I love Codeforces",
    "description": {
      "content": "Among participants of programming contests at codeforces.com the following tradition is common: whenever a participant falls in love with another participant, he changes his nickname to «_I_love__». U",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10134G"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Among participants of programming contests at codeforces.com the following tradition is common: whenever a participant falls in love with another participant, he changes his nickname to «_I_love__». U...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of supervisors.  \nLet $ m \\in \\mathbb{Z}^+ $ be the number of graduation project groups.\n\n**Constraints**  \n$ 1 \\leq n, m \\leq 10^3 $\n\n**Obje...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments