Simurgh

아직 제출이 없습니다시간 제한3초메모리 제한512 MB

문제

According to ancient Persian legends in Shahnameh, Zal, the legendary Persian hero, is madly in love with Rudaba, the princess of Kabul. When Zal asked for Rudaba's hand in marriage, her father gave him a challenge.

In Persia there are nn cities, labeled from 00 to n1n-1, and mm two-way roads, labeled from 00 to m1m-1. Each road connects a pair of distinct cities. Each pair of cities is connected by at most one road. Some of the roads are royal roads used for travels by royals. Zal's task is to determine which of the roads are the royal roads.

Zal has a map with all the cities and the roads in Persia. He does not know which of the roads are royal, but he can get help from Simurgh, the benevolent mythical bird who is Zal's protector. However, Simurgh does not want to reveal the set of royal roads directly. Instead, she tells Zal that the set of all royal roads is a golden set. A set of roads is a golden set if and only if:

  • it has exactly n1n-1 roads, and
  • for every pair of cities, it is possible to reach one from the other by traveling only along the roads of this set.

Furthermore, Zal can ask Simurgh some questions. For each question: 1. Zal chooses a golden set of roads, and then 1. Simurgh tells Zal how many of the roads in the chosen golden set are royal roads.

Your program should help Zal find the set of royal roads by asking Simurgh at most qq questions. The grader will play the role of Simurgh.

제한

  • 2n5002 \leq n\leq 500
  • n1mn(n1)/2n - 1 \leq m \leq n (n-1) / 2
  • 0u\[i],v\[i]n10 \leq u\[i], v\[i] \leq n-1 (for all 0im10 \leq i \leq m-1)
  • For all 0im10 \leq i \leq m-1, road ii connects two different cities (i.e., u\[i]v\[i]u\[i] \neq v\[i]).
  • There is at most one road between each pair of cities.
  • It is possible to travel between any pair of cities through the roads.
  • The set of all royal roads is a golden set.
  • find_roads should call count_common_roads at most qq times. In each call, the set of roads specified by rr should be a golden set.