Page 1 of 1
10504 - Hidden squares
Posted: Thu Jun 19, 2003 10:17 am
by saiqbal
i don't understand the 2nd sample input. i found only 7 squares for B in the following grid, but sample output says there are 8.
the squares i found for B are:
Code: Select all
1.
- B B -
- B B -
- - - -
- - - -
2.
- - - -
- B B -
- B B -
- - - -
3.
- - - -
- - - -
- B B -
- B B -
4.
- - - -
- - B B
- - B B
- - - -
5.
- B - -
B - B -
- B - -
- - - -
6.
- - B -
- B - B
- - B -
- - - -
7.
- - - -
- - B -
- B - B
- - B -
can someone please tell me where is the 8th square?
-sohel
Posted: Thu Jun 19, 2003 11:00 am
by turuthok
- - B -
B - - -
- - - B
- B - -
-turuthok-
Posted: Thu Jun 19, 2003 4:12 pm
by saiqbal
thanx.. that was really helpful
-sohel
10504-Can anyone give me some hint?
Posted: Thu Sep 11, 2003 11:12 am
by sunhong
I think about this problem for a long time. But I can't find good method to solve it. I'm afraid to get time limit excceed if I check every possible square. Can someone introduce how to solve it? Thank you!
Re: 10504-Can anyone give me some hint?
Posted: Thu Sep 11, 2003 11:27 am
by little joey
sunhong wrote:... I'm afraid to get time limit excceed if I check every possible square. ...
You'll never know if you don't try...
Posted: Fri Sep 12, 2003 8:54 am
by Ghost77 dimen
I have forgot which method I use for it.
But about O(n^4), pass it with not bad speed.
Posted: Mon May 09, 2005 9:33 am
by WR
If the input consists of an 100 x 100 grid with just capital A's. How many squares are there?
My program returns 10551500.
Is that correct?
Posted: Sun Sep 11, 2005 9:46 pm
by w k
My AC program for 100 x 100 square of capital A's gives:
8332500
Wojciech
10504
Posted: Wed Oct 12, 2005 7:35 am
by asif_rahman0
deleted
Posted: Tue Mar 28, 2006 5:32 am
by ThanhNhan
you need to check the bounds of the indexes for word[k+l-j][l-k+i]
Posted: Fri May 11, 2007 12:44 pm
by x140l31
One question about this problem.
I had Wrong Answer:
I think that the problem should be in the ooutput. I which order I have to write it?
In the input, after the "n lines" of the "square", what we have to do with the "letters"?
Sample Input
3
2
AAA
AAA
BAB
A <---- ?
B <---- ?
Sorry about my bad english '
Posted: Fri May 11, 2007 7:14 pm
by Jan
Check the cases caryfully. Hope these help.
Input:
Code: Select all
3
2
AAA
AAA
BAB
B
A
4
2
ABBA
BBBB
ABBB
ABBA
A
B
0
Output:
Posted: Tue May 15, 2007 1:20 pm
by x140l31
thx Jan

I got AC
WA!
Posted: Wed Oct 10, 2007 12:43 am
by MrBlah
Code: Select all
#include <stdio.h>
#include <string.h>
int main (){
int largo, x, y, q, p, n[26], cantletras, i, j, K;
char w[101][101],a[26];
while(scanf("%d", &largo)==1){
if (largo <= 0 || largo > 100) return 0;
getchar();
scanf("%d", &cantletras);
getchar();
for (i=0;i<26;i++) n[i]=0;
for (i=0;i<largo;i++){
scanf("%s", w[i]);
getchar();
K = strlen(w[i]);
w[i][K]='\0';
}
for (i=0;i<cantletras;i++){
scanf("%c", &a[i]);
getchar();
}
for (x=0; x<largo; x++)
{
for (y=0;y<largo;y++)
{
for (q=0; q<largo;q++)
{
for (p=1; p<largo; p++)
{
if ( (x+p+q<largo) && (x+p+q-p<largo) && (x+p+q-p>=0) && (y-q>=0) && (y-q+p<largo) && (y-q+p>=0) && (y-q+p+q<largo) && (y-q+p+q>=0) && (w[x][y] == w[x+p][y-q]) && (w[x+p][y-q] == w[x+p+q][y-q+p]) && (w[x+p+q][y-q+p] == w[x+p+q-p][y-q+p+q]))
{
for (j=0; j<26; j++)
{
if (a[j] == w[x][y])
{
++n[j];
break;
}
}
}
}
}
}
}
for (j=0;j<cantletras;j++){
printf("%c %d\n", a[j],n[j]);
}
printf("\n");
}
return 0;
}
I keep getting WA and i tested all the test casesin the board and got all of them right T_T WHY WA!??
Posted: Wed Oct 10, 2007 1:36 am
by Jan
You have to print a blank line between two consecutive cases, not after every case.