{"trustable":false,"prependHtml":"\u003cstyle type\u003d\u0027text/css\u0027\u003e\n .input, .output {\n border: 1px solid #888888;\n }\n .output {\n margin-bottom: 1em;\n position: relative;\n top: -1px;\n }\n .output pre, .input pre {\n background-color: #EFEFEF;\n line-height: 1.25em;\n margin: 0;\n padding: 0.25em;\n }\n \u003c/style\u003e\n \u003clink rel\u003d\"stylesheet\" href\u003d\"//codeforces.org/s/96598/css/problem-statement.css\" type\u003d\"text/css\" /\u003e\u003cscript\u003e window.katexOptions \u003d { disable: true }; \u003c/script\u003e\n\u003cscript type\u003d\"text/x-mathjax-config\"\u003e\n MathJax.Hub.Config({\n tex2jax: {\n inlineMath: [[\u0027$$$\u0027,\u0027$$$\u0027], [\u0027$\u0027,\u0027$\u0027]],\n displayMath: [[\u0027$$$$$$\u0027,\u0027$$$$$$\u0027], [\u0027$$\u0027,\u0027$$\u0027]]\n }\n });\n\u003c/script\u003e\n\u003cscript type\u003d\"text/javascript\" async src\u003d\"https://mathjax.codeforces.org/MathJax.js?config\u003dTeX-AMS_HTML-full\"\u003e\u003c/script\u003e","sections":[{"title":"","value":{"format":"HTML","content":"成都有 $n$ 家火锅店,编号从 $1$ 到 $n$,第 $i$ 家火锅店提供一定辣度的火锅。较高的辣度表示更辣的味道,而较低的辣度则更温和(但仍然需要非常小心)。\n\n我们可以将这 $n$ 家餐厅视为具有 $m$ 条边的无向图上的节点。现在我们有 $q$ 个游客想尝试一下火锅。给定游客当前的位置和他们所能承受的最大辣味值,你的任务是计算游客和他能接受的最近餐厅之间的最短距离。\n\n在这个问题中,我们将路径的距离定义为路径中的边数。"}},{"title":"Input","value":{"format":"HTML","content":"每个测试文件中只有一个测试用例。\n\n第一行包含三个整数 $n$、$m$ 和 $q$ $(1\\le n,m\\le 10^5, 1\\le q\\le 5×10^5)$ 表示餐厅数量、边数和游客数量。\n\n第二行包含 $n$ 个整数 $w_1,w_2,\\dots,w_n$ $(1\\le w_i\\le 100)$ 其中 $w_i$ 表示第 $i$ 家餐厅的辣味值。\n\n对于接下来的 $m$ 行,第 $i$ 行包含两个整数 $u_i$ 和 $v_i$ $(1\\le u_i, v_i\\le n, u_i\\neq v_i)$ 表示连接餐厅 $u_i$ 和 $v_i$ 的边。\n\n对于以下 $q$ 行,第 $i$ 行包含两个整数 $p_i$ 和 $a_i$ $(1\\le p_i\\le n, 1\\le a_i \\le 100)$,表示第 $i$ 个游客当前在餐厅 $p_i$,他可以吃的最大辣味值接受是 $a_i$。"}},{"title":"Output","value":{"format":"HTML","content":"输出 $q$ 行,其中第 $i$ 行包含一个整数,表示第 $i$ 位游客和他可以接受的最近餐厅之间的最短距离。如果没有这样的餐厅,则输出 $-1$。 "}},{"title":"Example","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e\n4 4 5\n5 4 2 3\n1 2\n2 3\n3 4\n4 1\n1 1\n1 2\n1 3\n1 4\n1 5\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e\n\n-1\n2\n1\n1\n0\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n"}}]}