#P12039. Minimum Press Count for Forcing Turnover
Minimum Press Count for Forcing Turnover
Minimum Press Count for Forcing Turnover
In a soccer game, the opponent has n players and only m pairs of players can directly pass the ball. When one of the opponents holds the ball, the coach can send x+1 players to press. One of these players challenges the ball‐handler and the remaining x players each block at most one pass route. Because the ball‐handler lacks fancy dribbling skills, he must immediately pass the ball through one of the available passing routes. If at any point the ball‐handler finds all his passing routes blocked, he loses possession.
This scenario can be modeled as follows. You are given an undirected simple graph with n nodes and m edges. A chess piece representing the ball is initially placed at some node i (which corresponds to one of the opposing players). Two players, A and B, then play a game in rounds. In each round:
- Player B removes at most x edges from the graph (these represent blocked passing routes).
- Player A moves the chess piece along one of the remaining edges to an adjacent node.
- Player B then restores the removed edges.
If, at the beginning of a round, the current node u has degree \(d(u)\) satisfying \(d(u) \le x\), then B can remove all edges incident on u and force A into a position with no move – a win for B.
More generally, when the piece is at some node \(u\) with \(d(u) > x\), player B can choose a subset \(S\) (with \(|S| \le x\)) of incident edges to remove. In order to force a win, B needs to ensure that for every remaining edge \((u,v)\) (i.e. for every possible move of A), the position at node \(v\) is winning for B. Formally, if we define a vertex \(u\) to be winning for B if either \(d(u) \le x\) or there exists a subset \(S \subseteq E(u)\) with \(|S| \le x\) such that for every edge \((u,v)\) not in \(S\), vertex \(v\) is winning for B, then B wins if from the starting vertex the game reaches a winning vertex in a finite number of moves.
Your task is: For every vertex \(i \in [1,n]\), find the minimum integer x such that, if the chess piece starts at vertex \(i\), player B can force a win in a finite number of rounds, assuming both players play optimally.
Note: The removal of edges by B in each round applies only for that round (i.e. the removed edges are immediately restored after A’s move). Nevertheless, the strategic blocking can be used to eventually force A into a vertex whose degree is at most \(x\), where B wins immediately.
Input Constraints: The graph does not contain self-loops or multiple edges.
inputFormat
The first line contains two integers \(n\) and \(m\) \((1 \le n \le 10^5,\ 0 \le m \le 10^5)\), representing the number of vertices and edges in the graph.
Each of the next \(m\) lines contains two integers \(u\) and \(v\) \((1 \le u,v \le n,\ u \neq v)\) indicating that there is an undirected edge connecting vertices \(u\) and \(v\).
The graph is simple (i.e. there are no self-loops or multiple edges).
outputFormat
Output a single line containing \(n\) integers. The \(i\)-th integer represents the minimum x such that player B can force a win (in finite rounds) when the chess piece starts at vertex \(i\). The numbers should be separated by a single space.
sample
3 2
1 2
2 3
1 1 1