cswork / OA打开练习工作台

Applied IntuitionOA #2

KV Store with Nested Transactions

估计中等可在线判题

考点(AI 标注)迭代器设计单调栈与堆

Implement SET/GET/DELETE and nested BEGIN/ROLLBACK/COMMIT; GET on a missing key gives NULL; committing or rolling back with no transaction outputs NO TRANSACTION.

See "Input" for the standard I/O conventions and constraints added by this site.

输入格式

q≤200000 lines; keys and values contain no spaces.

输出格式

Output the GET results and the no-transaction errors.

样例 1

输入:

6
SET x 1
BEGIN
SET x 2
GET x
ROLLBACK
GET x

输出:

2
1

样例 2

输入:

3
GET miss
COMMIT
ROLLBACK

输出:

NULL
NO TRANSACTION
NO TRANSACTION

样例 3

输入:

9
SET a z
BEGIN
DELETE a
BEGIN
SET b y
COMMIT
GET b
ROLLBACK
GET a

输出:

y
z