以下回答参考 皆我百晓生、券券喵儿 等免费微信小程序相关内容作答,并由本人整理回复。
# Parking Log
#
# Problem Description:
# The parking lot in the center of the capital has N parking spaces.
# You are asked to develop a program to write the parking log of the lot.
# The program is required to record such two operations which may happen in the lot:
# A: A motorcade with Mi cars applies for Mi parking spaces in a row,
# namely, continuous spaces [Si,Si+Mi-1].
# A special constraint is that the number of free spaces between the
# coming motorcade and the last car parking before Si, should not be
# larger than Li.
# Note that, this constraint has no effect if there is no car before Si.
# What's more, the number of free spaces between the coming motorcade
# and the first car parking after Si+Mi-1 should not be larger than Ri.
# Also, you should ignore this constraint when Si+Mi-1 is last
# occupied space.
# B: The k-th motorcade counted from left to right leaves the lot.
# Ignore this operation if there are no more than k motorcades in the
# parking lot.
#
# In the very beginning, the spaces in the lot are all free.
#
# Input:
# First line of the input is a single integer T(T <= 10), indicates there are T test cases.
# For each test case, the first line is two integers N(1 <= N <= 50000)
# Q(1 <= Q <= 100000), representing the size of the lot and the number of operations.
# The following Q lines give the operations, in which lines with one char and three integers
# as "A M L R" (0 < M,L,R <= 50000) representing operations of type A, and lines with one
# char and a single number are of type B.
#
# Output:
# For each test case, you should output "Case #k:"
# After that, your program should output the result place for each operation A,
# -1 if no place available.
#
# Constraints:
# 1 <= T <= 10
# 1 <= N, Q <= 50000
#
# Sample Input:
# 2
# 90 5
# A 77 2 2
# B 3
# B 1
# A 53 2 3
# A 7 3 3
# 7 15
# A 3 1 1
# A 1 1 1
# B 1
# A 1 1 1
# A 2 1 1
# A 1 1 1
# B 4
# B 3
# B 2
# A 1 1 1
# A 2 1 1
#
# Sample Output:
# Case #1:
# 1
# 1
# 54
# Case #2:
# 1
# 4
# 2
# 1
# 2
# 5
# 6
# -1
# -1
# 3
#' Parking Log
#' @param N number of parking spaces
#' @param Q number of operations
#' @return
#' 1. Result place for operation A
#' 2. -1 if no place available
#' @examples
#' parking_log <- parking_log(N = 90, Q = 5)
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2))
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2), B = 3)
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2), B = 3, B = 1)
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2), B = 3, B = 1, B = 1)
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2), B = 3, B = 1, B = 1, B = 2)
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2), B = 3, B = 1, B = 1, B = 2, B = 4)
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2), B = 3, B = 1, B = 1, B = 2, B = 4, B = 3)
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2), B = 3, B = 1, B = 1, B = 2, B = 4, B = 3, B = 2)
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2), B = 3, B = 1, B = 1, B = 2, B = 4, B = 3, B = 2, B = 4)
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2), B = 3, B = 1, B = 1, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3)
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2), B = 3, B = 1, B = 1, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2)
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2), B = 3, B = 1, B = 1, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4)
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2), B = 3, B = 1, B = 1, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4)
#' parking_log <- parking_log(N = 90, Q = 5, A = c(77, 2, 2), B = 3, B = 1, B = 1, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4, B = 3, B = 2, B = 4