#K65927. File Sharing System
File Sharing System
File Sharing System
You are given a file sharing system that maintains multiple projects. Each project may contain a collection of files. The system supports the following operations:
- C p: Create a project with ID
p
if it does not already exist. - D p: Delete the project with ID
p
if it exists. - U p f: Upload a file with ID
f
to projectp
if the project exists. When a file is uploaded, its download count is initialized to 0. If the file already exists in the project, nothing happens. - R p f: Remove (delete) the file with ID
f
from projectp
if it exists. - L p f: Download the file with ID
f
from projectp
. If the file exists, its download count is increased by 1 and the updated count is output; otherwise, output 0.
You are given the initial number of projects and their IDs, followed by a series of queries. For each query of type L
, you must print the download count result (one per line) to the standard output.
The download operation can be mathematically represented as follows. If we denote the previous download count by c, then after processing the query L p f
, the output is
\[
c' = c + 1
\]
provided the file exists; if not, the output is 0.
inputFormat
The first line of input contains two integers P
and Q
, where P
is the number of initial projects and Q
is the number of queries.
The second line contains P
space-separated integers representing the initial project IDs.
The next Q
lines each contain a query in one of the following formats: C p
, D p
, U p f
, R p f
, or L p f
.
Input is read from standard input.
outputFormat
For each query of type L
, output the corresponding download count on a separate line to standard output.
3 10
1 2 3
C 4
U 1 100
L 1 100
U 2 200
L 2 200
L 2 200
D 2
U 4 300
L 4 300
R 4 300
1
1
2
1
</p>