Edge First or Vertex First
Time limit8sMemory limit512 MB
Given a directed graph, Edgeo picks a probability distribution over edges, then Vertexko picks a distribution over vertices to minimize the expected score; find the game value.
- Level
Hard9 of 10
- Topics
- Game theory, Graph, Probability, Math
- Solved
- No attempts yet
Problem
The year is 2020, the age of grand graphs. The world has split into the Edge faction, which claims "graphs were born from edges first," and the Vertex faction, which claims "graphs were born from vertices first," and is mired in chaos. The ultimate form of the battle the two factions reached by clashing their claims is a two-player game using a graph. Today, Edgeo of the Edge faction and Vertexko of the Vertex faction are about to compete in this game.
In this game, a directed graph with N vertices and M edges is given first. The game proceeds through three phases in order: the first-player phase, the second-player phase, and the evaluation phase.
- First-player phase: The first player is Edgeo of the Edge faction, and in this phase Edgeo sets the probabilities for randomly choosing exactly one edge from the M edges. That is, for every edge, he freely assigns the probability ei that the i-th edge is chosen. Here each ei is a real number between 0 and 1 inclusive, and the sum of all ei must be exactly 1.
- Second-player phase: The second player, Vertexko of the Vertex faction, sets the probabilities for randomly choosing exactly one vertex from the N vertices. That is, for every vertex, she freely assigns the probability vj that the j-th vertex is chosen. As with the edges, each vj is a real number between 0 and 1 inclusive, and the sum of all vj must be exactly 1. The second player may assign her probabilities after freely seeing the probabilities the first player assigned to the edges.
- Evaluation phase: Based on the assigned probabilities, one edge and one vertex are determined independently at random. Depending on the relationship between the chosen edge and vertex, the game's score is determined as follows.
- If the vertex is the tail of the directed edge, the score is -1.
- If the vertex is the head of the directed edge, the score is 1.
- If the vertex is neither the tail nor the head of the directed edge, the score is 0.
In this game, the second player Vertexko of the Vertex faction assigns probabilities so as to minimize the expected score. This is, of course, because she believes vertices should come before edges. Meanwhile, the first player Edgeo of the Edge faction, taking into account that the second player Vertexko will use a strategy that minimizes the expected score, assigns probabilities so as to maximize the expected score. Needless to say, this is because he believes edges should come before vertices. For the given graph, find the expected score when both players assign probabilities to edges and vertices according to the above strategies.
Input
The input consists of at most 50 datasets. Each dataset is given in the following format.
N M
a1 b1
…
aM bM
The first line contains the number of vertices N (2 ≤ N ≤ 104) and the number of edges M (1 ≤ M ≤ 104) of the directed graph used in the game. The following M lines describe the directed edges of the graph. The i-th of the M lines indicates that the i-th edge goes from vertex ai (1 ≤ ai ≤ N) to vertex bi (1 ≤ bi ≤ N). The given graph has no self-loops, that is, ai ≠ bi holds for all 1 ≤ i ≤ M. The given graph has no multiple edges, that is, for all 1 ≤ i < j ≤ M, either ai ≠ aj or bi ≠ bj holds.
The end of the input is indicated by a line consisting of two zeros.
Output
For the given graph, output on one line the expected score of the game when both players use each of the above optimal strategies. The result must not contain an error of 10−10 or more.