-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsherlock.c
54 lines (52 loc) · 1.2 KB
/
sherlock.c
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
#include<stdio.h>
#include<stdlib.h>
long long int check[1001]={-1};
int main()
{
long long int t,n,i,j,flag,count,r,k;
char s[1001][1001];
scanf("%lld",&t);
while(t--)
{
scanf("%lld",&n);
//char s[n][n];
long long int check[n];
count=0;
for(i=0;i<n;i++)
{
for(j=0;j<n;j++)
{
//fflush(stdin);
scanf("%s",&s[i][j]);
//printf("%c",s[i][j]);
//fflush(stdin);
if(s[i][j]=='#')
check[j]=i;
}
}
//printf("%lld %lld",i,j);
for(j=n-1;j>=0;j--)
{
if(check[j]!=(n-1))
{
r=check[j]+1;
flag=0;
for(k=r;k<n;k++)
{
for(i=j;i<n;i++)
{
if(s[k][i]=='#')
{
flag=1;
break;
}
}
if(flag==0)
count++;
}
}
}
printf("%lld\n",count);
}
return 0;
}