QOJ.ac

QOJ

حد الوقت: 1.8 s حد الذاكرة: 256 MB مجموع النقاط: 100

#11551. 汽油

الإحصائيات

Byteasar 受雇于 Byteonian 石油巨头 Byteoil 的物流部门。他的工作是规划到各个加油站的燃油配送。

Byteotia 有 $n$ 个交叉路口(编号从 $1$ 到 $n$),以及连接某些交叉路口对的 $m$ 条双向道路。在某些交叉路口设有 Byteoil 加油站。

Byteoil 的运输车队由各种油箱容量的油罐车组成。每辆油罐车每行驶一公里消耗 $1$ 升燃油。因此可以认为,油箱容量为 $b$ 升的油罐车在无需加油的情况下,最大行驶距离为 $b$ 公里。司机不能使用油罐车主油箱中携带的燃油,但他们可以在任何 Byteoil 加油站免费加油。

Byteasar 的工作是反复回答以下询问:油箱容量为 $b$ 升的油罐车能否从位于交叉路口 $x$ 的加油站行驶到位于交叉路口 $y$ 的加油站?油箱容量为 $b$ 升的油罐车在两个 Byteoil 加油站之间行驶时,不能覆盖超过 $b$ 公里的距离。油罐车的起点始终位于设有 Byteoil 加油站的交叉路口,且所有行程的终点也位于设有 Byteoil 加油站的交叉路口。

请帮助 Byteasar 为他的物流查询提供自动回复。

输入格式

第一行包含三个整数 $n, s$ 和 $m$ ($2 \le s \le n \le 200\,000, 1 \le m \le 200\,000$),分别表示交叉路口的数量、加油站的数量和 Byteotia 的道路数量。

第二行包含一个由 $s$ 个两两不同的整数 $c_1, c_2, \dots, c_s$ ($1 \le c_i \le n$) 组成的序列,表示设有 Byteoil 加油站的交叉路口。

接下来的 $m$ 行描述了 Byteotia 的道路;其中第 $i$ 行包含三个整数 $u_i, v_i$ 和 $d_i$ ($1 \le u_i, v_i \le n, u_i \neq v_i, 1 \le d_i \le 10\,000$),表示第 $i$ 条道路长度为 $d_i$ 公里,连接交叉路口 $u_i$ 和 $v_i$。每对交叉路口之间最多只有一条道路。

下一行包含一个整数 $q$ ($1 \le q \le 200\,000$),表示查询的数量。接下来的 $q$ 行包含查询的描述;其中第 $i$ 行包含三个整数 $x_i, y_i$ 和 $b_i$ ($1 \le x_i, y_i \le n, x_i \neq y_i, 1 \le b_i \le 2 \cdot 10^9$),表示关于容量为 $b_i$ 升的油罐车能否从交叉路口 $x_i$ 的加油站行驶到交叉路口 $y_i$ 的加油站的查询。可以假设在交叉路口 $x_i$ 和 $y_i$ 处均设有 Byteoil 加油站。

输出格式

你的程序应输出恰好 $q$ 行。第 $i$ 行应包含一个单词 “TAK”(即是)或 “NIE”(即否),取决于容量为 $b_i$ 升的油罐车是否能够从交叉路口 $x_i$ 行驶到交叉路口 $y_i$。

样例

样例输入 1

6 4 5
1 5 2 6
1 3 1
2 3 2
3 4 3
4 5 5
6 4 5
4
1 2 4
2 6 9
1 5 9
6 5 8

样例输出 1

TAK
TAK
TAK
NIE

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.