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>(i, j) with a width of width clockwise width >= 2score <name> <score>score who's name is name<score> inside the range of [0,100]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:
n = m = 3, 0 < k, only <rotate> command0 < n,m < 9, 0 < k, only <rotate> command0 < n,m < 16, 0 < k0 < n,m, 0 < kThe 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 namescore: the student's initial scorei: which row the student initially seats onj: which column the student initially seats onThan the final k lines, each contains a action of what Tr.Potato wants to do.
Describe the best scored student in the following format:
"<name> at (<i>, <j>) scored <score>"
Check sample output for examples.