using
System;
using
System.Collections.Generic;
class
GFG
{
class
pair
{
public
int
first, second;
public
pair(
int
first,
int
second)
{
this
.first = first;
this
.second = second;
}
}
static
bool
checkCheckMate(pair []a,
int
n,
int
kx,
int
ky)
{
Dictionary<pair,
int
> mpp =
new
Dictionary<pair,
int
>();
for
(
int
i = 0; i < n; i++)
{
int
x = a[i].first;
int
y = a[i].second;
mpp.Add(
new
pair( x, y ), 1);
mpp.Add(
new
pair( x - 2, y + 1 ), 1);
mpp.Add(
new
pair( x - 2, y - 1 ), 1);
mpp.Add(
new
pair( x + 1, y + 2 ), 1);
mpp.Add(
new
pair( x + 1, y - 2 ), 1);
mpp.Add(
new
pair( x - 1, y + 2 ), 1);
mpp.Add(
new
pair( x + 2, y + 1 ), 1);
mpp.Add(
new
pair( x + 2, y - 1 ), 1);
mpp.Add(
new
pair( x - 1, y - 2 ), 1);
}
for
(
int
i = -1; i < 2; i++)
{
for
(
int
j = -1; j < 2; j++)
{
int
nx = kx + i;
int
ny = ky + j;
if
(i != 0 && j != 0)
{
pair p =
new
pair(nx, ny);
if
(mpp.ContainsKey(p))
{
return
true
;
}
}
}
}
return
false
;
}
public
static
void
Main(String[] args)
{
pair []a = {
new
pair( 1, 0 ),
new
pair( 0, 2 ),
new
pair( 2, 5 ),
new
pair( 4, 4 ),
new
pair( 5, 0 ),
new
pair( 6, 2 )};
int
n = a.Length;
int
x = 3, y = 2;
if
(checkCheckMate(a, n, x, y))
Console.WriteLine(
"Not Checkmate!"
);
else
Console.WriteLine(
"Yes its checkmate!"
);
}
}