fork download
  1. Manao works on a sports TV. He's spent much time watching the football games of some country. After a while he began to notice different patterns. For example, each team has two sets of uniforms: home uniform and guest uniform. When a team plays a game at home, the players put on the home uniform. When a team plays as a guest on somebody else's stadium, the players put on the guest uniform. The only exception to that rule is: when the home uniform color of the host team matches the guests' uniform, the host team puts on its guest uniform as well. For each team the color of the home and guest uniform is different.
  2.  
  3. マリオはスポーツ放送局で働いてます。彼はサッカーの観戦に非常に多くの時間を費やします。After a while he began to notice different patterns.
  4. 例えば、それぞれのチームにはホームユニフォームとゲストユニフォームの2種類のユニフォームがあります。チームがホームでゲームを行った場合、プレイヤーはホームユニフォームを着用します。また、チームがその他のスタジアムでゲストとしてプレイする場合、プレイヤーはゲストユニフォームを着用します。
  5. 上記のルールには1つだけ例外があります。それは、ホストチームのユニフォームの色がゲストチームのユニフォームと被ってしまった場合、ホストチームはゲストユニフォームを着用するということです。お互いのチームのユニフォームの色は異なっている必要があるのです。
  6.  
  7.  
  8. There are n teams taking part in the national championship. The championship consists of n·(n - 1) games: each team invites each other team to its stadium. At this point Manao wondered: how many times during the championship is a host team going to put on the guest uniform? Note that the order of the games does not affect this number.
  9.  
  10. ナショナルチャンピオンシップに n チーム参加します。このチャンピオンシップは全体で n * (n-1) 回ゲームが行われます。それぞれのチームはお互いのチームを自分たちのスタジアムに招待します。ここで、マリオに1つの疑問が生じました。チャンピオンシップの間にホストチームは何回ゲストユニフォームを着用するのか? Note that the order of the games does not affect this number.
  11.  
  12.  
  13. You know the colors of the home and guest uniform for each team. For simplicity, the colors are numbered by integers in such a way that no two distinct colors have the same number. Help Manao find the answer to his question.
  14.  
  15. あなたはそれぞれのチームのホームユニフォームとゲストユニフォームの色を知っています。ここでは簡単のために、色を整数として扱います。その際、2つの色が同じ数値となることはありえません。さあ、マリオのこの問いに答えを与えましょう!。
  16.  
  17.  
  18. Input
  19. The first line contains an integer n (2 ≤ n ≤ 30). Each of the following n lines contains a pair of distinct space-separated integers hi, ai (1 ≤ hi, ai ≤ 100) — the colors of the i-th team's home and guest uniforms, respectively.
  20.  
  21. 入力
  22. 最初の行は整数 (2 ≤ n ≤ 30) を含む。それに続く n 行は空白で区切られた異なる整数 hi, ai (1 ≤ hi, ai ≤ 100) の組を含みます。これは、i番目のホームユニフォームとゲストユニフォームの色を表しています。
  23.  
  24.  
  25. Output
  26. In a single line print the number of games where the host team is going to play in the guest uniform.
  27.  
  28. 出力
  29. ホストチームがゲストユニフォームを着て試合をする数を印字せよ。
  30.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty