#P9320. [EGOI 2022] Tourists / 乌托邦旅行团
[EGOI 2022] Tourists / 乌托邦旅行团
Background
Day 1 Problem D.
Translated from EGOI2022 tourists.
Problem Description
Utopia has cities, numbered from to , and bidirectional roads connecting these cities. Using only these roads, it is possible to travel between every pair of cities. Since Utopia is very beautiful, there are currently tourists, numbered from to , visiting the country. Initially, tourist is visiting city . Multiple tourists may be in the same city; that is, for , it is possible that .
Each tourist has a rating for how interesting their current trip in Utopia is, represented by a number, and all initial ratings are . To encourage tourists to explore more, the Utopian government hopes to increase tourists' ratings by organizing events in selected cities. When an event is held in city , the ratings of all tourists currently there increase by , where depends on the type of event.
Some tourists plan to travel between cities during their stay in Utopia. Although traveling from one city to another takes almost no time (thanks to the efficient Utopian roads), it is still an inconvenience and thus decreases the tourists' ratings. Specifically, if a tourist travels along a path consisting of roads, their rating decreases by (tourists always choose the shortest path between two cities).
The Utopian government asks you to record the tourists' ratings as they travel. As part of this requirement, you are given queries as input. You should answer all queries in the order they appear in the input.
Input Format
The first line contains three integers — the number of cities, the number of tourists, and the number of queries.
The second line contains integers , where is the initial city of tourist .
The next lines each contain two integers , indicating that there is a bidirectional edge between and .
The next lines each describe a query. Each line has one of the following three formats:
- First a letter
t, followed by three integers : all tourists with indices in travel to city . - First a letter
e, followed by two integers : city holds an event that increases ratings by . - First a letter
q, followed by one integer : ask for the current rating of tourist .
It is guaranteed that there is at least one operation q in the input.
Output Format
For each operation q, output one integer per line.
8 4 11
1 4 8 1
6 4
6 3
3 7
6 5
5 1
1 2
1 8
q 4
t 3 4 5
t 2 2 7
q 4
e 5 10
e 1 5
q 4
t 1 1 5
t 2 2 1
q 1
q 2
0
-1
9
4
-7
Hint
Constraints
For all testdata, , , . The input is guaranteed to form a tree. In operation t, , . In operation e, , . In operation q, .
- Subtask 1 ( points): .
- Subtask 2 ( points): .
- Subtask 3 ( points): .
- Subtask 4 ( points): there are no operations
e. - Subtask 5 ( points): no additional constraints.
Translated by ChatGPT 5
