| Real Questions | Practice Questions | Syllabus Analysis |
|---|---|---|
| Level 1 Real Questions List | Level 1 Practice Questions List | Level 1-5 Syllabus Analysis |
| Level 2 Real Questions List | Level 2 Practice Questions List | GESP/CSP Essential Programming Skills |
| Level 3 Real Questions List | Level 3 Practice Questions List | |
| Level 4 Real Questions List | Level 4 Practice Questions List | |
| Level 5 Real Questions List | Level 5 Practice Questions List |
| CSP-XL |
|---|
| 2025 Liaoning CSP-XL Re-examination Real Questions Analysis |
GESP Level 2 Practice, mathematical function focus, difficulty ★✮☆☆☆.
luogu-B3686 [Language Monthly Contest 202212] Luogu Delta
Problem Requirements
Problem Description
In the parallel Luogu world, there are three cities A, B, and C, which form the Luogu Delta.
There is a bidirectional road between each pair of cities. In other words, there are three roads: one between city A and city B, one between city A and city C, and one between city B and city C.
Due to different congestion levels on each road, the time required to travel through each road is also different. For each road, the bidirectional congestion level is the same (i.e., the time required to travel from city A to city B is the same as from city B to city A).
Traveling from city A to city B takes minutes, traveling from city B to city C takes minutes, and traveling from city C to city A takes minutes.
![GESP C++ Level 2 Practice: Luogu-B3686, [Language Monthly Contest 202212] Luogu Delta](https://boardor.com/wp-content/uploads/2026/01/4ebb3252-8e62-4e9d-a06f-fe9eceaba56f.png)
Due to business needs, the Luogu station master needs to frequently travel between the three cities. If he can know the shortest time to travel between any two cities, it will greatly improve his work efficiency.
So he now wants to know: from city A to city B, from city B to city C, and from city A to city C, how much time is required at least (in minutes). However, he thinks this problem is too difficult, so he has handed it over to you, who are clever.
Input Format
The input consists of one line with three integers, representing .
Output Format
The output consists of three lines: the first line is the minimum time required from city A to city B. the second line is the minimum time required from city B to city C. the third line is the minimum time required from city A to city C.
Sample Input #1
1 2 5
Sample Output #1
1
2
3
Sample Input #2
3 3 3
Sample Output #2
3
3
3
Hint
Sample 1 Explanation
Traveling from city A to city B takes minutes, traveling from city B to city C takes minutes.Traveling from city A to city C can be done by first going from city A to city B, and then from city B to city C, which only takes minutes.
Data Scale and Constraints
- For data, it satisfies ;
- For the other data, it satisfies ,;;
- For data, it satisfies .
Problem Analysis
The key to this problem is to understand that the shortest time from city A to city C is the minimum of the time from city A to city B plus the time from city B to city C and the direct time from city A to city C. Similarly, the shortest time from city B to city C is the minimum of the time from city B to city A plus the time from city A to city C and the direct time from city B to city C. The shortest time from city A to city B is the direct time from city A to city B.
Therefore, we can find the shortest time by comparing the direct time and the time through a transfer. Then output these shortest times.
In the code implementation, we can use the min function to compare the direct time and the time through a transfer, and output the minimum time.
Example Code
#include <cmath>
#include <iostream>
using namespace std;
int main() {
int x, y, z; // Define variables x, y, z
cin >> x >> y >> z; // Read values of x, y, z from input stream
cout << min(x, y + z) << endl; // Output the minimum of x and y+z
cout << min(y, x + z) << endl; // Output the minimum of y and x+z
cout << min(z, x + y) << endl; // Output the minimum of z and x+y
return 0;
}
【Recommended】Mobile Version Recommended:【GESP】C++ Certification Learning Resource Summary
【Recommended】Desktop Version Recommended: GESP/CSP Examination Material Website:https://wiki.coderli.com/ Dictionary-style resource organization, easy and quick to browse by category.
![GESP C++ Level 2 Practice: Luogu-B3686, [Language Monthly Contest 202212] Luogu Delta](https://boardor.com/wp-content/uploads/2026/01/cc2f3fca-cefd-4f15-bd34-70753bc1bc8b.png)
“luogu-” series problems can be evaluated online atLuogu Question Bank.
“bcqm-” series problems can be evaluated online atProgramming Enlightenment Question Bank.