No girl. TC is about to drop RP.
The opening was not smooth. It seems that TC arena has a problem. You can't use it and copy or paste it.
250PT:
I have not seen any important conditions, such as Mu you,! = B 2 * max (a, B) <min (numRows, numColumns)
With this condition, it is easy to judge that there is wood, and only the values may be 2, 3, 4, 6, or 8.
It indicates that no conditions are displayed. YY has been around for a long time. I think the discussion is too complicated.
Then I changed the writing method.
Consider eight directions. It is feasible to have a region in each direction. Obtain eight matrices, and then calculate matrix intersection, TAT.
The last 3 minutes, but it's okay, PST.
[Cpp]
Struct Node
{
Int x1, x2, y1, y2;
Node (){}
Node (int _ x1, int _ y1, int _ x2, int _ y2): x1 (_ x1), y1 (_ y1), x2 (_ x2 ), y2 (_ y2 ){}
};
Class HyperKnight
{
Public:
Int Bin (int num, int * a, int len)
{
Int low = 0, high = len-1, mid;
While (low <= high)
{
Mid = (low + high)/2;
If (a [mid] = num) return mid;
If (a [mid] <num) low = mid + 1;
Else high = mid-1;
}
}
LL countCells (int a, int B, int numRows, int numColumns, int k)
{
Int x [100], y [100], xcnt = 0, ycnt = 0;
If (k = 0) return 0;
If (a <B) swap (a, B );
Vector <Node> v; v. clear ();
If (numRows> B & numColumns>)
{
V. pb (Node (B + 1, a + 1, numRows + 1, numColumns + 1 ));
X [xcnt ++] = B + 1; x [xcnt ++] = numRows + 1;
Y [ycnt ++] = a + 1; y [ycnt ++] = numColumns + 1;
V. pb (Node (B + 1, 1, numRows + 1, numColumns-a + 1 ));
X [xcnt ++] = B + 1; x [xcnt ++] = numRows + 1;
Y [ycnt ++] = 1; y [ycnt ++] = numColumns-a + 1;
V. pb (Node (1, a + 1, numRows-B + 1, numColumns + 1 ));
X [xcnt ++] = 1; x [xcnt ++] = numRows-B + 1;
Y [ycnt ++] = a + 1; y [ycnt ++] = numColumns + 1;
V. pb (Node (1, 1, numRows-B + 1, numColumns-a + 1 ));
X [xcnt ++] = 1; x [xcnt ++] = numRows-B + 1;
Y [ycnt ++] = 1; y [ycnt ++] = numColumns-a + 1;
}
If (numRows> a & numColumns> B)
{
V. pb (Node (a + 1, B + 1, numRows + 1, numColumns + 1 ));
X [xcnt ++] = a + 1; x [xcnt ++] = numRows + 1;
Y [ycnt ++] = B + 1; y [ycnt ++] = numColumns + 1;
V. pb (Node (a + 1, 1, numRows + 1, numColumns-B + 1 ));
X [xcnt ++] = a + 1; x [xcnt ++] = numRows + 1;
Y [ycnt ++] = 1; y [ycnt ++] = numColumns-B + 1;
V. pb (Node (1, B + 1, numRows-a + 1, numColumns + 1 ));
X [xcnt ++] = 1; x [xcnt ++] = numRows-a + 1;
Y [ycnt ++] = B + 1; y [ycnt ++] = numColumns + 1;
V. pb (Node (1, 1, numRows-a + 1, numColumns-B + 1 ));
X [xcnt ++] = 1; x [xcnt ++] = numRows-a + 1;
Y [ycnt ++] = 1; y [ycnt ++] = numColumns-B + 1;
}
Sort (x, x + xcnt); sort (y, y + ycnt );
Xcnt = unique (x, x + xcnt)-x;
Ycnt = unique (y, y + ycnt)-y;
Int cnt [100] [100]; mem (cnt, 0 );
For (int I = 0; I <v. size (); I ++)
{
Int l = Bin (v [I]. x1, x, xcnt), r = Bin (v [I]. x2, x, xcnt)-1;
Int u = Bin (v [I]. y1, y, ycnt), d = Bin (v [I]. y2, y, ycnt)-1;
For (int p = l; p <= r; p ++) for (int j = u; j <= d; j ++) cnt [p] [j] ++;
}
LL ans = 0;
For (int I = 0; I <xcnt; I ++)
{
For (int j = 0; j <ycnt; j ++)
{
If (cnt [I] [j] = k)
{
Ans + = (LL) (x [I + 1]-x [I]) * (LL) (y [j + 1]-y [j]);
// Cout <x [I] <"" <x [I + 1]-1 <"" <y [j] <"" <y [I + 1]-1 <endl;
}
}
}
Return ans;
}
};
Struct Node
{
Int x1, x2, y1, y2;
Node (){}
Node (int _ x1, int _ y1, int _ x2, int _ y2): x1 (_ x1), y1 (_ y1), x2 (_ x2 ), y2 (_ y2 ){}
};
Class HyperKnight
{
Public:
Int Bin (int num, int * a, int len)
{
Int low = 0, high = len-1, mid;
While (low <= high)
{
Mid = (low + high)/2;
If (a [mid] = num) return mid;
If (a [mid] <num) low = mid + 1;
Else high = mid-1;
}
}
LL countCells (int a, int B, int numRows, int numColumns, int k)
{
Int x [100], y [100], xcnt = 0, ycnt = 0;
If (k = 0) return 0;
If (a <B) swap (a, B );
Vector <Node> v; v. clear ();
If (numRows> B & numColumns>)
{
V. pb (Node (B + 1, a + 1, numRows + 1, numColumns + 1 ));
X [xcnt ++] = B + 1; x [xcnt ++] = numRows + 1;
Y [ycnt ++] = a + 1; y [ycnt ++] = numColumns + 1;
V. pb (Node (B + 1, 1, numRows + 1, numColumns-a + 1 ));
X [xcnt ++] = B + 1; x [xcnt ++] = numRows + 1;
Y [ycnt ++] = 1; y [ycnt ++] = numColumns-a + 1;
V. pb (Node (1, a + 1, numRows-B + 1, numColumns + 1 ));
X [xcnt ++] = 1; x [xcnt ++] = numRows-B + 1;
Y [ycnt ++] = a + 1; y [ycnt ++] = numColumns + 1;
V. pb (Node (1, 1, numRows-B + 1, numColumns-a + 1 ));
X [xcnt ++] = 1; x [xcnt ++] = numRows-B + 1;
Y [ycnt ++] = 1; y [ycnt ++] = numColumns-a + 1;
}
If (numRows> a & numColumns> B)
{
V. pb (Node (a + 1, B + 1, numRows + 1, numColumns + 1 ));
X [xcnt ++] = a + 1; x [xcnt ++] = numRows + 1;
Y [ycnt ++] = B + 1; y [ycnt ++] = numColumns + 1;
V. pb (Node (a + 1, 1, numRows + 1, numColumns-B + 1 ));
X [xcnt ++] = a + 1; x [xcnt ++] = numRows + 1;
Y [ycnt ++] = 1; y [ycnt ++] = numColumns-B + 1;
V. pb (Node (1, B + 1, numRows-a + 1, numColumns + 1 ));
X [xcnt ++] = 1; x [xcnt ++] = numRows-a + 1;
Y [ycnt ++] = B + 1; y [ycnt ++] = numColumns + 1;
V. pb (Node (1, 1, numRows-a + 1, numColumns-B + 1 ));
X [xcnt ++] = 1; x [xcnt ++] = numRows-a + 1;
Y [ycnt ++] = 1; y [ycnt ++] = numColumns-B + 1;
}
Sort (x, x + xcnt); sort (y, y + ycnt );
Xcnt = unique (x, x + xcnt)-x;
Ycnt = unique (y, y + ycnt)-y;
Int cnt [100] [100]; mem (cnt, 0 );
For (int I = 0; I <v. size (); I ++)
{
Int l = Bin (v [I]. x1, x, xcnt), r = Bin (v [I]. x2, x, xcnt)-1;
Int u = Bin (v [I]. y1, y, ycnt), d = Bin (v [I]. y2, y, ycnt)-1;
For (int p = l; p <= r; p ++) for (int j = u; j <= d; j ++) cnt [p] [j] ++;
}
LL ans = 0;
For (int I = 0; I <xcnt; I ++)
{
For (int j = 0; j <ycnt; j ++)
{
If (cnt [I] [j] = k)
{
Ans + = (LL) (x [I + 1]-x [I]) * (LL) (y [j + 1]-y [j]);
// Cout <x [I] <"" <x [I + 1]-1 <"" <y [j] <"" <y [I + 1]-1 <endl;
}
}
}
Return ans;
}
};