5 5 1 2 2 3 3 1 3 4 4 5 2 1 0 5 2
Yes 10100 One way to satisfy the conditions is to paint vertices $1, 3$ black and vertices $2, 4, 5$ white. Indeed, for each $i = 1, 2, 3, 4, 5$, let $A_i$ denote the minimum distance between vertex $i$ and a vertex painted black, and we have $(A_1, A_2, A_3, A_4, A_5) = (0, 1, 0, 1, 2)$, where $A_1 = 0, A_5 = 2$.
5 5 1 2 2 3 3 1 3 4 4 5 5 1 1 2 1 3 1 4 1 5 1
No There is no way to satisfy the conditions by painting each vertex black or white, so you should print `No`.
1 0 0
Yes 1
{
"problem": {
"name": "Nearest Black Vertex",
"description": {
"content": "You are given a simple connected undirected graph with $N$ vertices and $M$ edges (a simple graph contains no self-loop and no multi-edges). For $i = 1, 2, \\ldots, M$, the $i$\\-th edge connects vert",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc299_e"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given a simple connected undirected graph with $N$ vertices and $M$ edges (a simple graph contains no self-loop and no multi-edges). \nFor $i = 1, 2, \\ldots, M$, the $i$\\-th edge connects vert...",
"is_translate": false,
"language": "English"
}
]
}