Logo
(追記) (追記ここまで)

23129번 - Counting Pairs 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 256 MB329932.143%

문제

You are given an undirected graph $G$ consisting of $N$ vertices, numbered from 1ドル$ to $N,ドル and $M$ edges.

Consider a pair of vertices $(a, b),ドル where $a < b$. Let the incidence of $(a, b)$ be the total number of edges with at least one of their endpoints being $a$ or $b$.

You have to answer $Q$ queries. Each query is given as an integer $k,ドル and asks how many pairs of vertices $(a, b)$ are there in $G$ such that $a < b$ and the incidence of $(a, b)$ is strictly greater than $k$.

입력

The first line of input contains two integers $N$ and $M,ドル the number of vertices and the number of edges (1ドル \le N, M \le 10^6$).

Then $M$ lines follow. The $i$-th of them contains two integers $x_i$ and $y_i,ドル denoting the endpoints of the $i$-th edge (1ドル \le x_i, y_i \le N$). There may be self-loops or parallel edges.

The next line of input contains one integer $Q,ドル the number of queries (1ドル \le Q \le 10^6$).

Then $Q$ lines follow. The $i$-th of them contains an integer $k_i,ドル denoting the $i$-th query (1ドル \le k_i \le 10^6$).

출력

For each query, print a single line with a single integer: the answer to the query.

제한

예제 입력 1

4 5
1 2
2 4
1 3
2 3
2 1
2
2
3

예제 출력 1

6
5

힌트

출처

Camp > Petrozavodsk Programming Camp > Summer 2021 > Day 4: 2021 Shanghai ICPC Camp Onsite 1 by PKU A번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /