using
System;
using
System.Collections.Generic;
public
class
GFG{
public
class
pair
{
public
int
first, second;
public
pair(
int
first,
int
second)
{
this
.first = first;
this
.second = second;
}
}
static
bool
range(
int
n,
int
x,
int
y)
{
return
(x <= n && x > 0 && y <= n && y > 0);
}
static
int
check(
int
n,
int
x,
int
y,
int
xx,
int
yy,
Dictionary <pair,
int
> mp)
{
int
ans = 0;
while
(range(n, x, y) && ! mp.ContainsKey(
new
pair(x, y)))
{
x += xx;
y += yy;
ans++;
}
return
ans;
}
static
int
numberofPosition(
int
n,
int
k,
int
x,
int
y,
int
[]obstPosx,
int
[]obstPosy)
{
int
x1, y1, ans = 0;
Dictionary <pair,
int
> mp =
new
Dictionary<pair,
int
>();
while
(k>0)
{
k--;
x1 = obstPosx[k];
y1 = obstPosy[k];
mp.Add(
new
pair(x1, y1), 1);
}
ans += check(n, x + 1, y, 1, 0, mp);
ans += check(n, x-1, y, -1, 0, mp);
ans += check(n, x, y + 1, 0, 1, mp);
ans += check(n, x, y-1, 0, -1, mp);
ans += check(n, x + 1, y + 1, 1, 1, mp);
ans += check(n, x + 1, y-1, 1, -1, mp);
ans += check(n, x-1, y + 1, -1, 1, mp);
return
ans;
}
public
static
void
Main(String[] args)
{
int
n = 8;
int
k = 1;
int
Qposx = 4;
int
Qposy = 4;
int
[]obstPosx = { 3 };
int
[]obstPosy = { 5 };
Console.Write(numberofPosition(n, k, Qposx, Qposy,
obstPosx, obstPosy) +
"\n"
);
}
}