DWARFLOG  Manipulate Dwarfs
In a small village beyond seven hills and seven seas, Snow White lives together with N dwarves who spend all their time eating and playing League of Legends. Snow White wants to put an end to this, so she has organized gym classes for them.
At the beginning of each class, the dwarves must stand in line, ordered by their height. For the purposes of this task, assume that the dwarves have heights 1, 2, ..., N (each exactly once) and initially all are standing in sorted order with height from 1 to N. Now Snow White play on them by issuing commands of the form:
• 1 X Y  dwarves with height X and Y in the line must switch places. She also checks their ordering by issuing queries of the form:
• 2 A B  do dwarves with heights A, A+1, ..., B (not necessarily in that order) occupy a contiguous subsequence of the current line? Help the doofus dwarves follow Snow White's instructions and respond to her queries.
INPUT
The first line of input contains the two positive integers N and M, the number of dwarves and the number of Snow White's requests, respectively (2 ≤ N ≤ 200 000, 2 ≤ M ≤ 200 000). Each of the following M lines contains a single Snow White's request, of the form "1 X Y" (1 ≤ X, Y ≤ N, X ≠ Y) or “2 A B” (1 ≤ A ≤ B ≤ N), as described in the problem statement.
OUTPUT
The output must contain one line for each request of type 2, containing the reply to the query, either “YES” or “NO”.
Example:
Input :
4 5
2 2 3
2 2 4
1 1 3
2 3 4
1 4 3
Output :
YES
YES
NO
hide comments
smso:
20180914 07:54:06
" contiguous subsequence of the current line" is vague: should be "consecutive ..., irrespective of order and indices" 

Rishav Goyal:
20151219 23:40:43
CHEATING CASE:


Hugo Hideki Yamashita [Unicamp]:
20150817 01:02:21
@gj2227 the problem says the form "2 A B" has (1 ≤ A ≤ B ≤ N) so your test case is invalid 

gj2227:
20150815 05:46:19
plzz tell me the expected output for the following test case


Akhilesh Anandh:
20150809 08:12:42
Time limit is quite strict... Last edit: 20150809 16:46:00 

gamer496:
20150801 10:09:51
Is there any other approach except using advanced ds (fenwick,segment)


eagle93:
20150728 09:06:27
Is there a better solution than O(n log^2 n)?


:.Mohib.::
20150726 21:09:47
really a very learning problem for me..!! 

Soma:
20150724 17:02:31
can some one explain me what does the line : "(not necessarily in that order) occupy a contiguous subsequence of the current line" mean? 

Pranjal Shankhdhar:
20150723 18:34:30
yay 
Added by:  Rishav Goyal 
Date:  20150722 
Time limit:  1s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 JSMONKEY 