cswork / OA打开练习工作台

RobloxOA #12

Rate Limit by Multiple Request Fields

估计中等可在线判题

考点(AI 标注)迭代器设计哈希计数

Each request has several field dimensions, and each dimension is configured with its own fieldName, window, and limit. A request is ALLOW only if no dimension exceeds its limit; this site explicitly uses the sliding window [timestamp-window,timestamp), and only ALLOW requests are counted in each dimension's history, so requests that get REJECT do not consume quota.

输入格式

The first line contains d q; then d lines of fieldName window limit; then q lines of timestamp value1 ... valued. Added by this site: 1≤d≤10, 1≤q≤200000, window and limit are positive integers, values contain no spaces, and timestamps are non-decreasing.

输出格式

For each request, output ALLOW or REJECT, separated by spaces.

样例 1

输入:

2 6
user 10 2
device 10 3
1 u1 d1
2 u1 d1
3 u1 d1
4 u2 d1
11 u1 d1
12 u1 d1

输出:

ALLOW ALLOW REJECT ALLOW ALLOW ALLOW

样例 2

输入:

2 4
user 5 1
endpoint 3 2
1 u1 /a
2 u1 /a
2 u2 /a
4 u2 /a

输出:

ALLOW REJECT ALLOW REJECT

样例 3

输入:

1 2
user 2 1
1 u
3 u

输出:

ALLOW ALLOW