답안 #15114

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
15114 2015-07-11T10:35:36 Z ggoh 빨간 직사각형 (kriii3_QQ) C++
10 / 20
1000 ms 87876 KB
#include<cstdio>
int a,b,i,c,j,k,ans,g,h,w[3333][3333],z[3333][3333];
char s[3333];
int sum(int x1,int y1,int x2,int y2)
{
	return z[x2][y2]-z[x2][y1-1]-z[x1-1][y2]+z[x1-1][y1-1];
}
main()
{
	scanf("%d%d",&a,&b);
	for(i=1;i<=a;i++)
	{
		scanf("%s",s);
		for(j=0;j<b;j++)
		{
			if(s[j]=='R')w[i][j+1]=1;
		}
	}
	for(i=1;i<=a;i++)
	{
		for(j=1;j<=b;j++)
		{
			z[i][j]=z[i][j-1]+w[i][j];
		}
	}
	for(i=1;i<=a;i++)
	{
		for(j=1;j<=b;j++)
		{
			z[i][j]+=z[i-1][j];
		}
	}
	for(i=1;i<=a;i++)
	{
		for(j=i;j<=a;j++)
		{
			h=0;
			for(k=1;k<=b+1;k++)
			{
				if(sum(i,k,j,k)==j-i+1)
				{
					h++;
				}
				else
				{
					ans+=h*(h+1)/2;
					h=0;
				}
			}
		}
	}
	printf("%d",ans);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 87876 KB Output is correct
2 Correct 0 ms 87876 KB Output is correct
3 Correct 0 ms 87876 KB Output is correct
4 Correct 0 ms 87876 KB Output is correct
5 Correct 0 ms 87876 KB Output is correct
6 Correct 0 ms 87876 KB Output is correct
7 Correct 0 ms 87876 KB Output is correct
8 Correct 0 ms 87876 KB Output is correct
9 Correct 1 ms 87876 KB Output is correct
10 Correct 1 ms 87876 KB Output is correct
11 Correct 0 ms 87876 KB Output is correct
12 Correct 0 ms 87876 KB Output is correct
13 Correct 0 ms 87876 KB Output is correct
14 Correct 0 ms 87876 KB Output is correct
15 Correct 0 ms 87876 KB Output is correct
16 Correct 0 ms 87876 KB Output is correct
17 Correct 0 ms 87876 KB Output is correct
18 Correct 0 ms 87876 KB Output is correct
19 Correct 0 ms 87876 KB Output is correct
20 Correct 0 ms 87876 KB Output is correct
21 Correct 133 ms 87876 KB Output is correct
22 Correct 198 ms 87876 KB Output is correct
23 Correct 184 ms 87876 KB Output is correct
24 Correct 131 ms 87876 KB Output is correct
25 Correct 186 ms 87876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 87876 KB Output is correct
2 Correct 101 ms 87876 KB Output is correct
3 Execution timed out 1000 ms 87876 KB Program timed out
4 Halted 0 ms 0 KB -