2935 - I2P(I)2023_Hu_Lab10 Scoreboard

Time

2023/12/27 17:00:00 2023/12/27 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14156 Merge Sort Magic
14168 Great Debate

14156 - Merge Sort Magic   

Description

HA! You activated my trap card! Now you must sort my cards using the merge sort algorithm.

Merge Sorting is an essential way to sort arrays. The algorithm is a 'divide and conquer' algorithm. In other words, it divides the input array into two halves, calls itself for the two halves, and then merges the two sorted halves. 

The following is a pseudocode for the algorithm:

MergeSort(arr[], l,  r)
If r > l
     1. Find the middle point to divide the array into two halves:  
             middle m = l+ (r-l)/2
     2. Call mergeSort for first half:   
             Call mergeSort(arr, l, m)
     3. Call mergeSort for second half:
             Call mergeSort(arr, m+1, r)
     4. Merge the two halves sorted in step 2 and 3:
             Call merge(arr, l, m, r)

For this problem, you must write the mergesort function is already provided, so you only need to code the following function:

void merge(int*, int, int, int);

Now sort these cards or else you will be sent to the shadow realm.

Input

the first line contains the integer N (1 <= N <= 5000)

The following N lines contain the integers to be sorted. (1 <= num <= 5000)

Output

The process of the sorting (already provided by the partial judge) and the final value of the sorting.

Sample Input  Download

Sample Output  Download

Partial Judge Code

14156.c

Partial Judge Header

14156.h

Tags




Discuss




14168 - Great Debate   

Description

In an alternate universe, arguements are won through strength instead of intellect; therefore whenever someone disagrees with someone else, they initiate a duel with one another until only one of them is left standing.

One day, Aurick was arguing with his senior, Dunqian, about whether or not cereal is a soup. Because they cannot seem to agree with each other, they must duel.

The mechanic of the duel is as follows:

  • The duel can only last for 20 rounds. If both duelists are still standing, then they will duel again the next day.
  • Each duelist has 9 variables:
    • Name
    • Health
    • Strength
    • Magic
    • Healing Power
    • Defense
    • Resistance
    • Move
  • When the match starts, duelists will perform their action at the same time. After they perform their action, they must switch to the next attack type.
  • The next move is determined by a simple loop:
    • Magical  -> Physical
    • Physical -> Heal
    • Heal -> Magical
  • Because the each duelists attack at the same time, there are three possible scenarios that can occur:
    • Duelist A wins
    • Duelist B wins
    • Draw (either both of them getting knocked out or agfter 20 rounds has passed)

(If the Defense/Resistance stat is more than the Strength/Magic stat, the damage dealt will be 0) 

Your job is to code the following functions:

void magicalAttack(struct Duelist* self, struct Duelist* target); (attack using magic against resistance, switch to physical attack)

void physicalAttack(struct Duelist* self, struct Duelist* target); (attack using physical against defense, switch to heal)

void heal(struct Duelist* self, struct Duelist* target); (heal user's hp,  switch to magical attack)

struct Duelist getDuelist();

*Do not forget to include the struct and the 4 function declaration at the top of the submitted code*

**Healing can go over the starting health value**

Input

The input comes in 2 lines.

Each line contains the variables of each participant as follows:

name - health - strength - magic - healing power - defense - resistance - move

(0 <= stats <= 100)

Output

The health value of each duelist every round (already done in main)

The result of the match (already done in main)

Sample Input  Download

Sample Output  Download

Partial Judge Code

14168.c

Partial Judge Header

14168.h

Tags




Discuss