| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 14785 | Potato's Class |
|
| 14786 | Rotating Potato |
|
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 ofwidthclockwise
it's guaranteed thatwidth >= 2score <name> <score>
means that Potato wants to adjust student's score toscorewho's name isname
note that you have to cap<score>inside the range of[0,100]
a.k.a ifscore > 100make it100, ifscore < 0make it0
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 = 3,0 < k, only <rotate> command - Testcase 2 ~ 3:
0 < n,m < 9,0 < k, only <rotate> command - Testcase 4 ~ 5:
0 < n,m < 16,0 < k - Testcase 6:
0 < n,m,0 < 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 namescore: the student's initial scorei: which row the student initially seats onj: 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
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 < 100,0 < k - Testcase 6:
0 < n,m,0 < 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.