3354 - I2P(I)2026_Lo_Hw3 Scoreboard

Time

2026/09/22 00:00:00 2026/10/05 18:00:00

Clarification

# Problem Asker Description Reply Replier Reply Time For all team

# Problem Pass Rate (passed user / total user)
14996 Lucky Queue
15008 Printer War
15011 That Time I Got Reincarnated as a Roomba I

14996 - Lucky Queue   

Description

A pay-to-win Roblox game is hosting an event, they want to gift their loyal gamers some Robux. They would like to surprise the players in the waiting room.

When the announcement is made, there are already groups waiting in the room. There are also groups still logging in, these groups join the back of the queue, in the order given, and are included in the draw.

You are the developer tasked to build the algorithm to determine which group and how many Robux the owner of the game have to gift.

Here are the rules:

  • Counting from the front of the queue, groups at positions 1, k+1, 2k+1, … win. (Every k-th group, starting with the first.)
  • Every player in a winning group receives 67 Robux.

Input

The first line is the current queue, given as pairs of a group name and its size: group1 size1 group2 size2 …

The second line is the incoming queue, in the same format. This line may be blank if no new groups are logging in.

The third line is an integer k.

This link may help you in processing the input: https://www.geeksforgeeks.org/python/zip-in-python/

Constraints:

  • The current queue contains at least 1 group.
  • Group names contain no spaces. Group names consist of letters and digits only.
  • 1 <= group size <= 100
  • 1 <= total number of groups <= 1000
  • 1 <= k <= 1000 (k may exceed the number of groups)

Output

The first line is a Python list of the names of the winning groups, in queue order.

The second line is the total amount of Robux the game owner has to spend.

Sample Input  Download

Sample Output  Download




Discuss




15008 - Printer War   

Description

There’s a printing war going on in The Office. Everyone in the office can no longer print whatever and whenever they want. Michael and Dwight are the protector of the printer, and they need your help to manage the printing queue!

You will receive Q commands, and each command is either SUBMIT, PRINT, CANCEL, and STATUS . Here are the rules in details:

  • For SUBMIT, the command shape will look like this: SUBMIT <user> <file> <pages>
    • <file> must be <name>.<ext>, where:
      • <name> is at least 1 character, using only ABCDEFGHIJKLMNOPQRSTUVWXYZ, abcdefghijklmnopqrstuvwxyz, 0123456789, _- and <ext> is exactly pdf, txt or docx (lowercase). Otherwise, output REJECT BADNAME.
    • <pages> must be digits only, 1 ≤ pages ≤ 100, if it is not within range, output REJECT BADPAGES .
    • Each employee has a quota to submit the pages that they want to print, and that is 50 pages total; if exceed, then output REJECT QUOTA .
    • If the submission is a success, you output OK <id> . The <id> is the i-th validated printing job in the queue.
    • <user> is 1-20 alphanumeric characters, case-sensitive.
  • For PRINT , the command shape will look like this: PRINT <n>
    • You need to print out/remove (or pop, in a queueing term) n jobs (n is integer), from the oldest to the latest.
    • If there are any printing queued, then you have to output PRINTED <id> <user> <file> . Printing fewer than n jobs is not an error and does not produce IDLE.
    • If queue was empty, output IDLE .
  • For CANCEL , the command shape will look like this: CANCEL <user>
    • You need to remove all that user’s jobs still in the queue, and refund their quota. You need to output CANCELLED <count> . <count> is how many jobs got cancelled.
  • For STATUS, the command shape will look like this: STATUS
    • You need to output QUEUE <len> followed with a line of the front job NEXT <id> <user> .
    • If there’s no queue, then output NEXT NONE .
  • You need to output TOTAL <pages_printed> after all the commands have finished being inputted, followed with line(s) of who printed ≥ 1 page, sorted by pages descending, and then name ascending, i.e. <user> <pages> .
  • You also need to make sure that the commands are in the proper shape, if not, output REJECT BADREQUEST .

Michael and Dwight thank your services!

Note: Crash Course about Loop: https://hackmd.io/@gladysvalerie/S1wWLYCYze

Input

First line: integer Q (1 ≤ Q ≤ 1000)

Next Q lines: one command each, tokens separated by single spaces, according to the rules explained in the description.

Anything else described from the description, outputs REJECT BADREQUEST and the command is ignored.

Command keywords are uppercase.

Output

Per command, checked in this exact order:

SUBMIT

  1. <file> fails ^[A-Za-z0-9_-]+\.(pdf|txt|docx)$ → REJECT BADNAME
  2. <pages> not digits, or not 1 ≤ pages ≤ 100 → REJECT BADPAGES
  3. used[user] + pages > 50 → REJECT QUOTA
  4. otherwise → OK <id>

Ids start at 1 and increase by 1 per accepted job only; rejected submissions never consume an id. A job keeps its id after leaving the queue.

PRINT <n>

  • Queue empty → IDLE (one line, regardless of n).
  • Otherwise pop min(n, queue_length) jobs from the front, one PRINTED <id> <user> <file> line each. n = 0 on a non-empty queue outputs nothing.

CANCEL <user>

  • Remove all of that user's queued jobs, refund those pages to their quota, output CANCELLED <count>. Unknown user → CANCELLED 0. Already-printed pages are never refunded. <count> is how many jobs got cancelled.

STATUS

  • QUEUE <len>, then NEXT <id> <user> for the front job, or NEXT NONE if empty.

After all Q commands:

  • TOTAL <pages_printed> — exactly once.
  • Then one line <user> <pages> per user who printed ≥ 1 page, sorted by pages descending, then username ascending. Users with 0 printed pages are omitted entirely.

Sample Input  Download

Sample Output  Download




Discuss




15011 - That Time I Got Reincarnated as a Roomba I   

Description

Oh no! You got electrocuted by spilling coffee on your laptop and you are now reincarnated as a Roomba. You look at your surroundings, and it's a normal living room, but it's dirty. As a good Roomba, you need to help your owner clean it up. Your owner is bossy, so he just tells you the living room's grid dimension and the direction of the path you need to take.

You have a bumper sensor, so when a command would put you outside the room, you refuse to move and wait for the next one. Every tile you enter gets cleaned, and you keep a running total of everything you've absorbed. Here are the exact rules:

  • The room is a grid of R rows and C columns. Rows and columns are 0-indexed; row 0 is the top (north) and column 0 is the left (west).
  • If a command would take you outside of the room, you do not move at all, you skip the command and you go on to read the next command.
  • If you receive the command STOP, your shift ends immediately. Every command after STOP counts as skipped. STOP itself is not counted.
  • If the commands run out, your shift has ended.
  • When you move the full <steps> tiles, you clean every tile you pass through, including the one you land on. You absorb that tile's dirt, and it becomes 0. Your starting tile is not cleaned at the start of the shift; you only clean tiles you enter.
  • At the end of your shift, report your final location, the total dirt you absorbed, and how many commands you skipped.

Note: Crash Course about Loop: https://hackmd.io/@gladysvalerie/S1wWLYCYze

Input

In the first line, you will input five integers: com R C sr sc . com is the number of commands you will receive from your owner, R C are the dimension of the room’s grid size, sr sc are your starting point in the grid.

The next R lines describe the room: C digits each, where each digit (0-9) is that tile’s dirt level.

The next com lines are each either <dir> <steps>, where <dir> is one of N, S, E, W and <steps> is a positive integer, or the single word STOP.

Constraints

  • 1 ≤ com ≤ 100
  • 1 ≤ R, C ≤ 100
  • 0 ≤ sr < R, 0 ≤ sc < C (the start is always inside the room)
  • Each tile's dirt level is a single digit, 0–9
  • <dir> is one of N, S, E, W
  • 1 ≤ <steps> ≤ 100
  • Each command is either <dir> <steps> or STOP, and there are exactly com of them

Output

In the first line, output your final position fr fc final row and final column.

The second line, output the total dirt you collected.

The third line, output the number of commands skipped.

Sample Input  Download

Sample Output  Download




Discuss