forked from mohitsh/SPOJ
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkrow.cpp
81 lines (81 loc) · 1.35 KB
/
krow.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// 2008-08-05
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
int main()
{
int xwin=0;
int owin=0;
int t,X,Y,K,i,j,k;
char board[200][200];
scanf("%d",&t);
while (t--)
{
scanf("%d %d %d\n",&X,&Y,&K);
for (i=0; i<Y; i++)
gets(board[i]);
bool xw=false;
bool ow=false;
for (i=0; i<Y; i++)
for (j=0; j<=X-K; j++)
{
bool b1=true,b2=true;
for (k=j; k<j+K; k++)
{
if (board[i][k]-'x')
b1=false;
if (board[i][k]-'o')
b2=false;
}
if (b1) xw=true;
if (b2) ow=true;
}
for (i=0; i<X; i++)
for (j=0; j<=Y-K; j++)
{
bool b1=true,b2=true;
for (k=j; k<j+K; k++)
{
if (board[k][i]-'x')
b1=false;
if (board[k][i]-'o')
b2=false;
}
if (b1) xw=true;
if (b2) ow=true;
}
for (i=0; i<=X-K; i++)
for (j=0; j<=Y-K; j++)
{
bool b1=true,b2=true;
for (k=0; k<K; k++)
{
if (board[j+k][i+k]-'x')
b1=false;
if (board[j+k][i+k]-'o')
b2=false;
}
if (b1) xw=true;
if (b2) ow=true;
}
for (i=0; i<=X-K; i++)
for (j=K-1; j<Y; j++)
{
bool b1=true,b2=true;
for (k=0; k<K; k++)
{
if (board[j-k][i+k]-'x')
b1=false;
if (board[j-k][i+k]-'o')
b2=false;
}
if (b1) xw=true;
if (b2) ow=true;
}
if (xw)
xwin++;
if (ow)
owin++;
}
printf("%d:%d\n",xwin,owin);
return 0;
}