3257 - I2P(I)2025_Chou_Hu_Hw5_ClassA Scoreboard

Time

2025/10/20 20:30:00 2025/10/27 18:30:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14785 Potato's Class
14786 Rotating Potato

14785 - Potato's Class   

Description

It's again the time when Tr.Potato changes students' seats and adjust their scores, help Potato find where the best scored student seats after score and seat adjustments.

 

When Tr.Potato says:

  • rotate <i> <j> <width>
    means that Potato wants to rotate students seats in a matrix starting from top left at (i, j) with a width of width clockwise 
    it's guaranteed that width >= 2
  • score <name> <score>
    means that Potato wants to adjust student's score to score who's name is name
    note that you have to cap <score> inside the range of [0,100]
    a.k.a if score > 100 make it 100, if score < 0 make it 0

 

 

class Student:
    instances = {}

    def __init__(self, name, score, i, j):
        self.name = name
        self.score = score
        self.i = i
        self.j = j

    def set_score(self, score:int) -> None:
        pass # TODO set the new score for this student, and make sure the score is in valid range

    def get_message(self) -> str:
        pass # TODO get the message by the required format


class PotatosClass:
    students = dict()

    def __init__(self, n, m):
        self.seats = [[None]*m for _ in range(n)]

    def record_students(self):
        for i in range(n*m):
            name, score, i, j = input().split()

            score, i, j = int(score), int(i), int(j)

            student = Student(name, score, i, j)
            self.students[name] = self.seats[i][j] = student

    def command_score(self, stu_name:str, new_score:int) -> None:
        self.students[stu_name].set_score(new_score)

    def command_rotate(self, i:int, j:int, width:int) -> None:
        pass # TODO rotate the student's seats

    def get_best_student(self) -> Student:
        pass # TODO get the best scored student


n, m, k = map(int, input().split())

course = PotatosClass(n, m)
course.record_students()

for i in range(k):
    commands = input().split()

    if(commands[0] == "score"):
        course.command_score(commands[1], int(commands[2]))
    elif(commands[0] == "rotate"):
        course.command_rotate(int(commands[1]), int(commands[2]), int(commands[3]))

print(course.get_best_student().get_message())

 

Potato's Whisper: It's highly recommanded to use the above code, since it saves you alots of time. 

 

Potato judges your code by the following limitations:

  • Testcase 1:
    n = m = 30 < k, only <rotate> command
  • Testcase 2 ~ 3:
    0 < n,m < 90 < k, only <rotate> command
  • Testcase 4 ~ 5:
    0 < n,m < 160 < k
  • Testcase 6:
    0 < n,m0 < k

Input

The first line contains 3 integer n,m,k, representing the classroom's size is nxm and Tr.Potato will be doing k actions.

Following by n*m lines, each contains 4 elements (name, score, i, j):

  • name: the student's name
  • score: the student's initial score
  • i: which row the student initially seats on
  • j: which column the student initially seats on

Than the final k lines, each contains a action of what Tr.Potato wants to do.

Output

Describe the best scored student in the following format:

"<name> at (<i>, <j>) scored <score>"

Check sample output for examples.

Sample Input  Download

Sample Output  Download

Tags




Discuss




14786 - Rotating Potato   

Description

Potato wants to go brrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrotating. He's got a grid of numbers, and wanted to rotate it clockwise multiple times.

So, as a lovely kind student, you must be happy to write a program that quickly help him get the final result.

Potato judges your code by the following limitations:

  • Testcase 1:
    n = m = 2, 0 < k < 4
  • Testcase 2 ~ 3:
    0 < n = m < 9, 0 < k < 4
  • Testcase 4 ~ 5:
    0 < n,m < 1000 < k
  • Testcase 6:
    0 < n,m0 < k

Input

The first line contains 3 integer n,m,k, representing the grid's size if nxm, and Potato's gonna rotate it clockwise by k times.

Following by n lines, each containing m integers, forming the grid.

Output

Output the final grid after the k-th rotation.

Sample Input  Download

Sample Output  Download

Tags




Discuss