Peer Review

AtCoder
IDabc442_c
Time2000ms
Memory256MB
Difficulty
There are $N$ researchers, numbered $1, 2, \ldots, N$. There are $M$ conflicts of interest among the researchers; for $i = 1, 2, \ldots, M$, researchers $A_i$ and $B_i$ have a conflict of interest with each other. The reviewers of a paper must be three distinct researchers who are different from the author of the paper and have no conflict of interest with the author. For $i = 1, 2, \ldots, N$, solve the following problem: * Find the number of possible triples of reviewers for a paper authored by researcher $i$. Assume that all papers are single-authored. ## Constraints * $1 \leq N \leq 2 \times 10^5$ * $0 \leq M \leq 2 \times 10^5$ * $1 \leq A_i, B_i \leq N$ * $A_i \neq B_i$ * $(A_i, B_i) \neq (A_j, B_j)$ if $i \neq j$. * $(A_i, B_i) \neq (B_j, A_j)$ if $i \neq j$. * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $M$ $A_1$ $B_1$ $A_2$ $B_2$ $\vdots$ $A_M$ $B_M$ [samples]
Samples
Input #1
6 5
1 2
1 4
2 3
5 3
3 1
Output #1
0 1 0 4 4 10

Below, we represent a set of researchers by the set of their numbers.

*   There are no possible triples of reviewers for a paper authored by researcher $1$.
    
*   The possible triple of reviewers for a paper authored by researcher $2$ is $\lbrace 4, 5, 6 \rbrace$, which is $1$ triple.
    
*   There are no possible triples of reviewers for a paper authored by researcher $3$.
    
*   The possible triples of reviewers for a paper authored by researcher $4$ are $\lbrace 2, 3, 5 \rbrace, \lbrace 2, 3, 6 \rbrace, \lbrace 2, 5, 6 \rbrace, \lbrace 3, 5, 6 \rbrace$, which is $4$ triples.
    
*   The possible triples of reviewers for a paper authored by researcher $5$ are $\lbrace 1, 2, 4 \rbrace, \lbrace 1, 2, 6 \rbrace, \lbrace 1, 4, 6 \rbrace, \lbrace 2, 4, 6 \rbrace$, which is $4$ triples.
    
*   The possible triples of reviewers for a paper authored by researcher $6$ are $\lbrace 1, 2, 3 \rbrace, \lbrace 1, 2, 4 \rbrace, \lbrace 1, 2, 5 \rbrace, \lbrace 1, 3, 4 \rbrace, \lbrace 1, 3, 5 \rbrace, \lbrace 1, 4, 5 \rbrace, \lbrace 2, 3, 4 \rbrace, \lbrace 2, 3, 5 \rbrace, \lbrace 2, 4, 5 \rbrace, \lbrace 3, 4, 5 \rbrace$, which is $10$ triples.
Input #2
7 3
1 2
3 4
5 6
Output #2
10 10 10 10 10 10 20
Input #3
6 9
3 6
2 5
2 3
4 3
1 5
6 2
3 1
5 3
2 4
Output #3
1 0 0 1 0 1
API Response (JSON)
{
  "problem": {
    "name": "Peer Review",
    "description": {
      "content": "There are $N$ researchers, numbered $1, 2, \\ldots, N$. There are $M$ conflicts of interest among the researchers; for $i = 1, 2, \\ldots, M$, researchers $A_i$ and $B_i$ have a conflict of interest wit",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 2000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "abc442_c"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "There are $N$ researchers, numbered $1, 2, \\ldots, N$.\nThere are $M$ conflicts of interest among the researchers; for $i = 1, 2, \\ldots, M$, researchers $A_i$ and $B_i$ have a conflict of interest wit...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments