using
System;
using
System.Collections.Generic;
class
Program
{
static
void
AnswerQueries(
string
S1,
string
S2,
int
N,
int
T, List<
int
[]> Q)
{
int
curScore = 0;
for
(
int
i = 0; i < N; i++)
{
if
(S1[i] == S2[i])
{
curScore += 1;
}
}
Queue<
int
> q =
new
Queue<
int
>();
for
(
int
i = 0; i < Q.Count; i++)
{
if
(q.Count > 0 && q.Peek() == i)
{
int
idx = i - T;
q.Dequeue();
if
(S1[idx] != S2[idx])
{
curScore -= 1;
}
}
int
type = Q[i][0];
if
(type == 1)
{
int
pos = Q[i][1];
if
(S1[pos - 1] != S2[pos - 1])
{
curScore += 1;
}
q.Enqueue(i + T);
}
else
if
(type == 2)
{
int
string1 = Q[i][1], pos1 = Q[i][2], string2 = Q[i][3], pos2 = Q[i][4];
if
(S1[pos1 - 1] == S2[pos1 - 1])
{
curScore -= 1;
}
if
(pos1 != pos2 && S1[pos2 - 1] == S2[pos2 - 1])
{
curScore -= 1;
}
if
(string1 == 1 && string2 == 1)
{
char
[] s1Array = S1.ToCharArray();
char
temp = s1Array[pos1 - 1];
s1Array[pos1 - 1] = s1Array[pos2 - 1];
s1Array[pos2 - 1] = temp;
S1 =
new
string
(s1Array);
}
else
if
(string1 == 1 && string2 == 2)
{
char
[] s1Array = S1.ToCharArray();
char
[] s2Array = S2.ToCharArray();
char
temp = s1Array[pos1 - 1];
s1Array[pos1 - 1] = s2Array[pos2 - 1];
s2Array[pos2 - 1] = temp;
S1 =
new
string
(s1Array);
S2 =
new
string
(s2Array);
}
else
if
(string1 == 2 && string2 == 1)
{
char
[] s1Array = S1.ToCharArray();
char
[] s2Array = S2.ToCharArray();
char
temp = s2Array[pos1 - 1];
s2Array[pos1 - 1] = s1Array[pos2 - 1];
s1Array[pos2 - 1] = temp;
S1 =
new
string
(s1Array);
S2 =
new
string
(s2Array);
}
else
{
char
[] s2Array = S2.ToCharArray();
char
temp = s2Array[pos1 - 1];
s2Array[pos1 - 1] = s2Array[pos2 - 1];
s2Array[pos2 - 1] = temp;
S2 =
new
string
(s2Array);
}
if
(S1[pos1 - 1] == S2[pos1 - 1])
{
curScore += 1;
}
if
(pos1 != pos2 && S1[pos2 - 1] == S2[pos2 - 1])
{
curScore += 1;
}
}
else
{
if
(curScore == N)
{
Console.Write(
"YES "
);
}
else
{
Console.Write(
"NO "
);
}
}
}
Console.WriteLine();
}
static
void
Main()
{
string
S1 =
"cool"
;
string
S2 =
"club"
;
List<
int
[]> Q =
new
List<
int
[]> {
new
int
[] { 2, 1, 2, 2, 3 },
new
int
[] { 2, 2, 2, 2, 4 },
new
int
[] { 1, 2 },
new
int
[] { 3 },
new
int
[] { 3 } };
int
T = 2;
int
N = S1.Length;
AnswerQueries(S1, S2, N, T, Q);
string
S11 =
"aaab"
;
string
S21 =
"bbba"
;
List<
int
[]> Q1 =
new
List<
int
[]>
{
new
int
[] { 2, 1, 3, 2, 4 },
new
int
[] { 3 },
new
int
[] { 2, 1, 2, 2, 2 },
new
int
[] { 3 },
new
int
[] { 2, 1, 4, 2, 1 },
new
int
[] { 3 },
new
int
[] { 2, 1, 2, 2, 1 },
new
int
[] { 3 }
};
int
T1 = 2;
int
N1 = S11.Length;
AnswerQueries(S11, S21, N1, T1, Q1);
}
}