F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Bilibili

Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 2    Accepted Submission(s): 1


Problem Description
  Cdfpysw loves to watch videos at bilibili.com.
  When he watch videos, he can write some comments, and they will be shown on his screen.
  His screen has size of n * m, and every word has size of 1 * 1. When Cdfpysw send a comment, it'll be shown on the rightmost of the topmost line which doesn't contain any comment. If there are comments in all lines, this comment will be failed to send. Every second, the comments on the screen will be shifted to left for 1 before the new comments be send.
  e.g.:
  Now, the following picture is the screen. Cdfpysw wants to write 3 comments at now, 1 second later, and 6 seconds later. They will be shown on the 2nd line, 5th line, and 1st line.
  

  This example is NOT same as the sample below!
  Now Cdfpysw wants to know his comments would be shown on which line, if the comment is failed to send, print "Failed!".
 

Input
  The first line is an integer T, means the number of cases.
  For each case
    The first line contains 3 integers, n, m, q, means the size of screen and the number of comments Cdfpysw wants to send.
    Then q lines, for each line, there are 2 integers t, l, means the sending time and the length of the comment. It is guaranteed that t is in ascending order.

  T <= 10
  1 <= n, m, q <= 50000
  0 <= t <= 109
  1 <= l <= 109
 

Output
  For each case, you should print "Case #i:" in a line, i is the case number.
  Then q lines, each line contains an integer to represent the line to show the comment or a string "Failed!" to represent the comment is failed to send.
 

Sample Input
1 5 5 7 0 3 4 3 7 5 8 1 9 10 10 5 11 5
 

Sample Output
Case #1: 1 2 3 1 4 5 Failed!
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2025 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.001001(s) query 1, Server time : 2025-03-29 19:16:02, Gzip enabled