Summary
This article presents solutions to problems 1-3 from the 2024 Rui Kang Robot Developer Competition CAIP-Programming Skills Contest (Undergraduate Division, Provincial Level). The author completed 3 problems during the competition and provides detailed solutions for these, along with problem descriptions and key points for problems 4-5 which will be addressed in a separate article.
Problem 1: Hot Days Calculation (10 points)
Description
A restaurant chain offers free soda on days with temperatures of 35°C or higher. However, the promotion is suspended on Thursdays. Given a sequence of temperatures for consecutive days and the starting day of the week, calculate how many days you can get free soda and how many days you would have qualified but couldn't get soda due to it being Thursday.
Input format:
- First line: Two positive integers N, W (1 ≤ N ≤ 50, 1 ≤ W ≤ 7), where N is the number of consecutive days and W is the day of the week for the first day (7 = Sunday).
- Second line: N integers separated by spaces, each representing the temperature for that day (≥ -273°C).
Output format:
- Two numbers: The first is the count of days you can get free soda, the second is the count of days you would have qualified but couldn't due to Thursday.
Sample input:
15 3
33 35 34 36 37 40 32 31 30 29 28 29 33 38 40
Sample output:
5 1
Approach
This problem requires simulation of days of the week. We can track the day of the week by incrementing the initial day number and using modulo 7 to determine the current day. The mapping is as follows:
| Modulo Result | Day of Week |
|---|---|
| 0 | Sunday |
| 1 | Monday |
| 2 | Tuesday |
| 3 | Wednesday |
| 4 | Thursday |
| 5 | Friday |
| 6 | Saturday |
Complete Solution
#include <iostream>
using namespace std;
int main() {
int days, start_day;
int qualified_days = 0, thursday_losses = 0;
cin >> days >> start_day;
for (int i = 0; i < days; i++) {
int temperature;
cin >> temperature;
if (temperature >= 35) {
if ((start_day + i) % 7 == 4) { // Thursday
thursday_losses++;
} else {
qualified_days++;
}
}
}
cout << qualified_days << " " << thursday_losses << endl;
return 0;
}</iostream>
Problem 2: Tournament Qualification (15 points)
Description
Xepa Legends is a first-person battle royale game with 20 teams of 3 players each. The winning team is called the "Defender." Recently, an online competition for the Asia-Pacific South region was held, with 7 spots available for the offline competition in Mannheim, Germany. Fourteen domestic teams participated. Your task is to determine which teams qualified for the offline competition based on thier performance across multiple games.
In each game, every team receives a ranking and a kill count (number of enemy players eliminated). A team's score for a game is calculated as kills + ranking points. The ranking points are determined by the team's position in that game according to a specific scoring table.
Approach
To solve this problem, we need to:
- Process the results of N games for each team.
- Calculate the total score for each team across all games.
- Rank teams by their total scores to determine qualification.
- Identify which teams qualified for the offline competition.
Complete Solution
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Team {
int id;
int total_score;
vector<int> game_scores;
};
bool compareTeams(const Team &a, const Team &b) {
return a.total_score > b.total_score;
}
int main() {
int num_teams = 14;
int num_games;
cin >> num_games;
vector<team> teams(num_teams);
for (int i = 0; i < num_teams; i++) {
teams[i].id = i + 1;
teams[i].total_score = 0;
teams[i].game_scores.resize(num_games);
}
// Input game results
for (int game = 0; game < num_games; game++) {
for (int team = 0; team < num_teams; team++) {
int rank, kills;
cin >> rank >> kills;
// Calculate score based on rank and kills
int rank_points;
if (rank == 1) rank_points = 15;
else if (rank == 2) rank_points = 12;
else if (rank == 3) rank_points = 10;
else if (rank <= 5) rank_points = 8;
else if (rank <= 10) rank_points = 5;
else rank_points = 2;
int score = kills + rank_points;
teams[team].game_scores[game] = score;
teams[team].total_score += score;
}
}
// Sort teams by total score
sort(teams.begin(), teams.end(), compareTeams);
// Output qualified teams (top 7)
for (int i = 0; i < 7; i++) {
cout << teams[i].id << " ";
}
cout << endl;
return 0;
}</team></int></algorithm></vector></iostream>
Problem 3: Stove and Capybara (20 points)
Description
This problem involves optimizing resource allocation in a scenario with a stove and capybaras. The exact problem details are not provided in the original article, but it appears to involve scheduling or resource management with specific constraints related to the stove and capybaras.
Problems 4 and 5
Problem 4: Octopus Graph Judgment (25 points)
This problem appears to involve graph theory, specifically related to octopus graphs. The exact problem details and key concepts are not provided in the original article.
Problem 5: Work Arrangement (30 points)
This problem likely involves scheduling or optimization of work tasks with certain constraints. The exact problem details and key concepts are not provided in the original article.