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 (with indexes ranging from ). Initially, all elements are set to . However, Note that due to the unusual memory constraints of this problem, you cannot actually create an array of size
Next, there are operations, each of which has two forms:
set i x: Assign the value of array index to .get i: Output the value of array index .
If the index accessed in the operation is outside the range , the output should output Segmentation Fault.
Input
The first line consists of two space-separated integers , , representing the array size and the number of operations.
The next lines contain one operation each, \texttt{set i x} or \texttt{get i}, where and .
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