Submit | All submissions | Best solutions | Back to list |
SID - Search Insert Delete |
You are given a bunch of data (all are positive 32 bit numbers) to operate on. The only operations on the data are search, insert, and delete. When storing the data you have to remember its rank, that is the original position when the data is being inserted. All successful operations must return the ranks of the data. Failed operations should return NONE as the answer.
Your objective is to execute all of the operations as fast as possible.
Input
The first line of input is N and M, separated by a space, N is the number of initial data. (0 <= N < 1000000) and M is the number of operations against the data. (0 <= M < 1000000).
The second line contains N data, separated by blanks. All data are positive 32 bits numbers
The next M lines contains operations against the data. Each line contains a symbol and a number, separated by a space.
There are 3 symbols (S, I, D), each representing search, insert, and delete operation.
'S number' tries to find the number in the stored data, and outputs its first rank in the stored data (as originally inserted), or NONE if no such number exists.
'I number' inserts the number into the stored data, and outputs its rank in the stored data. (Data can be duplicated).
'D number' deletes the least ranked number found in the stored data, and outputs its rank, or NONE if no such number originally exists.
Output
There is an output for each executed operation. See the above input description about each operation for the detail of the output.
Example
Input:
10 6
20 12 10 28 20 50 49 8 51 1
S 20
I 3
S 11
D 20
I 2
S 20
Output:
1
11
NONE
1
12
5
Added by: | Jimmy Tirtawangsa |
Date: | 2012-10-28 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | ADA95 ASM32-GCC C-CLANG C NCSHARP CSHARP C++ 4.3.2 CPP CPP14 CPP14-CLANG C99 COBOL FORTRAN GO GOSU JAVA JULIA KTLN LUA OBJC OBJC-CLANG PAS-GPC PAS-FPC PYTHON PYPY PYPY3 PYTHON3 RUST |
Resource: | Own problem |
hide comments
|
||||||
2013-02-08 07:40:07 :D
Well somethings changed since I have an AC now. I will open it for now. Please e-mail me if you think there are still issues. |
||||||
2012-12-24 07:32:35 (Tjandra Satria Gunawan)(曾毅昆)
I like this kind of problem very much, please fix this problem as soon as possible... |
||||||
2012-11-14 04:31:39 david_8k
Please, let me know when this problem gets fixed :D |
||||||
2012-11-07 07:53:46 :D
So I understand you didn't run you're sample solution before setting up the problem. Before making it visible you must do that, especially since you put a very strict time limit, high constrains and went for an old cluster. Verify that is't doable. |
||||||
2012-11-04 02:55:49 Mitch Schwartz
@Jimmy Tirtawangsa: That shouldn't be the issue; the "stderr" page truncates program output at a certain point, so in those cases you can't see the full user output (this seems reasonable in order to save hard drive space on SPOJ servers). If a program's output exceeds the allowed limit, there will be a SIGXFSZ (exceeded file size) runtime error. |
||||||
2012-11-04 02:29:37 Jimmy Tirtawangsa
Yup. Sorry guys. There is output limitation from spoj that I didn't realise. So your output are all truncated, hence are not the same as reference output. I'll change the problem statement so that the output will be shorter. In the mean time, the problem is remain hidden. |
||||||
2012-11-01 17:51:59 :D
Yes, not saying that I'm 100% sure, but I did a decent amount of testing. It maybe due to some reading problems when buffering, but you made the constrains so tight that it's pretty much required. Test files should have no formatting issues. |
||||||
2012-11-01 13:41:26 :D
I'm hiding it for now. I'm in the process of writing O(N+M) solution (somewhat at least). I'll make extensive brute force tests. If it will fail (WA or TLE) it will be left closed until problem is corrected or setter shows me that those are only issues or solvers parts. |
||||||
2012-11-01 11:53:22 Ahmed AKram
something is wrong with the data please re-check the input/output |
||||||
2012-11-01 00:44:18 david_8k
Is it everything good with the input/output data? Last edit: 2012-11-01 00:50:05 |