#JSUTCPC2026I. Recall (Contest) —— 追忆 (Contest)
Recall (Contest) —— 追忆 (Contest)
Problem Description
I often reminisce about the past.
Moments of life are captured in my mind. I trim, fold, and crumple the time behind me, twisting it into fluffy white clouds in the sky.
Clouds also differ: cumulus clouds are thick and heavy, while cirrus clouds are ethereal. Scenes that have shocked my mind in life are unforgettable for a lifetime, while more ordinary memories only leave behind some remnants under the erosion of time. Recollections are like entering a dream; being too clear cannot delight one's own illusions, while being too vague can lead to nothingness. Only the mountains and rivers between the mist, the woman under the veil, and that just-right haziness can satisfy my exacting demands for beauty.
Memories always inadvertently enfold me in yellowing pages. Friends who parted and reunited, streets that were torn down and rebuilt, all these clues assist me in starting from a specific moment and flowing upstream along the river of time. The past cannot be repeated, and I am merely a passerby. Yet, I still yearn to leave some leisure time in every journey of recollection, to pause before a scene, to look back at my past self in the haze of years, and to feel as much sweetness as possible. The beautiful moments once flowed through my body, and I am content.
The past has solidified, and I carry my memories forward, yet often neglecting to preserve them, causing them to change shape. This brings some challenges to my journey of reminiscing.
Where should I stop? I asked myself.
Please note the completely unusual space constraint in this problem!
In the past years, Timothy has retained memories. As time goes by, he finds that directly storing all memories not only occupies excessive space but also makes searching extremely slow. He decides to organize his memories into a "virtual array" (with subscript range of ) of length , where only memories that have been truly touched will be stored.
So you need to help Timothy maintain a virtual array with a length of . Initially, all positions in the array have a value of . You need to handle operations, and the operation format is as follows:
set i x: Assign the value to the position of array index .get i: Output the value of array index .
For any operation, if the accessed index is not within the valid range of , output Segmentation Fault.
Input
The first line contains two integers ($1 \leqslant N \leqslant 5\times 10^{7}, 1 \leqslant Q \leqslant 10^5$), representing the length of the array and the number of operations, respectively.
Next, there are lines, with each line describing an operation:
set i x: Assign the value to the position of array index , satisfying .get i: Output the value of array index , satisfying .
To be precise, we will provide the input format as follows:
N Q
<Operation 1>
<Operation 2>
...
<Operation Q>
Output
For the set operation, if it is valid, output OK; otherwise, output Segmentation Fault.
For the get operation, if it is valid, output the value at that position; otherwise, output Segmentation Fault.
Samples
50000000 5
set 12345 99
get 12345
get 54321
set 50000000 1
get -1
OK
99
0
Segmentation Fault
Segmentation Fault