#P11644. 【MX-X8-T3】「TAOI-3」地地爱打卡

【MX-X8-T3】「TAOI-3」地地爱打卡

Background

Original problem link: https://oier.team/problems/X8D.


One year ago, I failed miserably at NOIP 2023.

One year later, I stood up again from where I fell.

THUWC 2025 D1T1, I forcefully scored 76 points.

... Segment-tree-optimized DP is just too hard.

Problem Description

Student T is very indifferent about running. To make running even more boring, he decided to make an app called "Didi Loves Check-ins", so that users cannot check in for running anywhere.

After finishing development, Student T plans to do a trial run, and he asked Student Y to help.

In this check-in trial, there are nn nodes numbered 1n1 \sim n, and mm undirected roads connecting two nodes. It is guaranteed that the graph has no multiple edges and no self-loops. Student Y needs to run from ss to tt.

Initially, Student Y's energy value is 00. Each time Student Y runs along a road, Student T will treat him to a meal, increasing his energy value by 11. During the trial, his energy value cannot be negative.

Student Y also has a happiness value, initially 00. When staying at some node, Student Y may choose to bitwise XOR his happiness value with his energy value, and then clear his energy value (i.e. set energy to 00), or do nothing.

Now Student Y wants to know whether he can finally stay at node tt, use up all his energy (i.e. energy becomes 00), and at that moment his happiness value is exactly xx? Note: after Student Y reaches node t\bm t, he may choose not to stop and continue moving.

Because Student Y loves running, you need to answer qq queries. Each query gives s,t,xs, t, x, and you need to tell Student Y whether he can meet his requirement.

Input Format

The first line contains three non-negative integers n,m,qn, m, q.

The next mm lines each contain two positive integers u,vu, v, representing a road connecting node uu and node vv.

The next qq lines each contain three non-negative integers s,t,xs, t, x, representing a query.

Output Format

Output qq lines. For each query, if Student Y can meet his requirement, output tribool; otherwise output expand.

7 6 4
2 4
5 6
1 2
3 5
3 6
7 1
1 2 1
1 6 3
5 3 5
2 7 7
tribool
expand
tribool
expand

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

tribool
expand
tribool
expand

Hint

[Sample Explanation #1]

As shown in the figure, for the first query, Student Y starts from node 11, goes along one road and arrives at node 22. At this time his energy value is 11. He then performs one operation: his energy value becomes 00, and his happiness value becomes 11, which satisfies the requirement.

For the second query, it can be shown that there is no valid plan.

[Constraints]

This problem uses bundled testdata.

  • Subtask 1 (22 points): max(n,m,q,x)50\max(n, m, q, x) \leq 50.
  • Subtask 2 (22 points): m=n1m = n - 1 and the graph is connected.
  • Subtask 3 (24 points): x1x \leq 1.
  • Subtask 4 (32 points): no special constraints.

For all testdata, it is guaranteed that 2n2×1052 \leq n \leq 2\times 10^5, 0m3×1050 \leq m \leq 3\times 10^5, 1q2×1051 \leq q \leq 2\times 10^5, 1s,t,u,vn1 \leq s, t, u, v \leq n, 0x1090 \leq x \leq 10^9, and the given undirected graph has no multiple edges and no self-loops.

Translated by ChatGPT 5