#P8327. [COCI 2021/2022 #5] Radio

    ID: 9375 远端评测题 1500ms 512MiB 尝试: 0 已通过: 0 显示难度省选/NOI− 上传者: 标签>2021COCI(克罗地亚)

[COCI 2021/2022 #5] Radio

Problem Description

There are nn radio stations in Croatia, all initially turned off. If two stations i,ji,j are turned on at the same time and i,ji,j are not coprime, then they will interfere with each other.

You need to write a program that supports the following operations:

  1. S x: Toggle the status of station xx, i.e., turn it off if it is on, and turn it on if it is off.
  2. C l r: Check whether there exists interference within [l,r][l,r]. If it exists, output DA; otherwise output NE.

Input Format

The first line contains two positive integers n,qn,q, representing the number of radio stations and the number of operations.

The next qq lines describe the operations. The exact input format is given in the statement description.

Output Format

For each C operation, output DA or NE.

6 8
S 1
S 2
S 3
C 1 6
S 6
C 1 6
S 2
C 1 6
NE
DA
DA
11 6
S 4
S 10
C 3 11
C 2 7
S 6
C 2 7
DA
NE
DA
20 7
S 10
S 15
S 3
C 10 15
S 10
C 3 15
C 3 10
DA
DA
NE

Hint

[Sample 1 Explanation]

Index of C Operation Turned-on Stations Interference?
11 1,2,31,2,3 No
22 1,2,3,61,2,3,6 Yes
33 1,3,61,3,6

[Constraints and Notes]

This problem uses bundled testdata.

  • Subtask 1 (10 pts): 1n1001 \le n \le 100, 1q2001 \le q \le 200.
  • Subtask 2 (30 pts): For all C operations, l=1,r=nl=1,r=n.
  • Subtask 3 (70 pts): No additional constraints.

For 100%100\% of the testdata, 1n1061 \le n \le 10^6, 1q2×1051 \le q \le 2 \times 10^5, 1xn1 \le x \le n, 1lrn1 \le l \le r \le n.

[Source] COCI 2021-2022#5 Task 4 Radio.

Translated by ChatGPT 5