传统题 1000ms 16MiB

Segmentation Fault——段错误

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Statement

Student: Teacher, why does Segmentation Fault occur?

Teacher: If you only store the locations that are actually used, you won't waste memory; similarly, only when you exist can you be found.

Please note the completely unusual memory constraints for this problem!

Timothy's C program keeps throwing segmentation faults when using large arrays. After researching online, he discovered that null pointer access is a common and simple type of segmentation fault. A null pointer access is an attempt to operate on the memory area at address 0. Since this memory area is prohibited from access, the process receives a SIGSEGV signal and a segmentation fault.

Timothy decides to write a ``dummy array": data is only stored at the index position it is used for. You have a dummy array of length NN (with indexes ranging from 0N10 \sim N-1). Initially, all elements are set to 00. However, Note that due to the unusual memory constraints of this problem, you cannot actually create an array of size NN

Next, there are QQ operations, each of which has two forms:

  1. set i x: Assign the value of array index ii to xx.
  2. get i: Output the value of array index ii.

If the index ii accessed in the operation is outside the range [0,N1][0, N-1], the output should output Segmentation Fault.

Input

The first line consists of two space-separated integers N,QN,Q, 1N109,1Q1051 \leq N \leq 10^{9}, 1 \leq Q \leq 10^5, representing the array size and the number of operations.

The next QQ lines contain one operation each, \texttt{set i x} or \texttt{get i}, where 0i1090\leq i\leq 10^9 and 230i230-2^{30}\leq i\leq 2^{30}.

Precisely, we provide the input in the following format:

N Q
<operation 1>
<operation 2>
...
<operation Q>

Output

For a get operation, if it is legal, it outputs OK; otherwise, it outputs Segmentation Fault.

For a get operation, if it is legal, it outputs the value at the location; otherwise, it outputs Segmentation Fault.

Samples

1000000000 5
set 12345 99
get 12345
get 54321
set 1000000000 1
get ‐1
OK
99
0
Segmentation Fault
Segmentation Fault

2025 JSUT Collegiate Programming Contest 江苏理工学院新生赛-同步赛

未参加
状态
已结束
规则
ACM/ICPC
题目
15
开始于
2025-11-8 12:00
结束于
2025-11-8 17:00
持续时间
5 小时
主持人
参赛人数
15