## 12405 - Scarecrow

Moderator: Board moderators

### 12405 - Scarecrow

please give me some sample input & output...
I got WA 3 times
riazur_cse
New poster

Posts: 2
Joined: Sun Jan 08, 2012 4:38 am

### Re: 12405

Code: Select all
`85.....5..*..10....##..#.10.....#....9....#....12....#....#..10..#..##...13..#..##....#.`
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson

plamplam
Experienced poster

Posts: 151
Joined: Fri May 06, 2011 11:37 am

### 12405

#include<stdio.h>
#include<math.h>
#include<string.h>

int main()
{
char inp[500];
int test,i,k,cnt,t,n,j;
char ch;
scanf("%d",&test);
for(t=1;t<=test;t++)
{
memset(inp,0,sizeof(inp));
scanf("%d",&n);
scanf("%s",&inp);
cnt=0;
for(i=0;i<n;i++)
{
if(inp[i]=='.' || inp[i]=='#')
{
if((inp[i-1]=='.' && i>=0) && (inp[i+1]=='.' && i<n))
{
inp[i]='1';
inp[i-1]='1';
inp[i+1]='1';
cnt++;
}
}
}
for(i=0;i<n;i++)
{
if(inp[i]=='.')
{
if((inp[i-1]=='.' && i>=0))
{
inp[i]='1';
inp[i-1]='1';
cnt++;
}
else if((inp[i+1]=='.' && i<n))
{
inp[i]='1';
inp[i+1]='1';
cnt++;
}
else
{
cnt++;
}
}
}
printf("Case %d: %d\n",t,cnt);
}
return 0;
}

pls check whtz wrng with this one....I dont understand.
Thanks..
riazur_cse
New poster

Posts: 2
Joined: Sun Jan 08, 2012 4:38 am

### Re: 12405

Hello, try this input...
I think ur code does not work for this input..think easily, its a easy problem
2
10
..#..##...
13
..#..##....#.

out:
Case 1: 3
Case 2: 4

ASU(SUST)
robot
New poster

Posts: 29
Joined: Sun May 24, 2009 8:39 pm

### Re: 12405

output for plamplam's input

Code: Select all
`Case 1: 2Case 2: 2Case 3: 4Case 4: 4Case 5: 3Case 6: 4Case 7: 3Case 8: 4`
leobonalume
New poster

Posts: 5
Joined: Mon May 09, 2011 8:49 pm

### Re: 12405

Generator by: Jane Alam Jan
http://www.LightOj.com
Sample Input: (By Generator)
Code: Select all
`493...11...##....##2##42..#.#...#.........#.#..#..#.......#.......40.#...#.#........#...#.#.##.........#..#.46#.#.##.............#.......##.....#...#.....#.62.#...............#.....##.....#.#......#.##.#.##......##..#.#.87......#..#..#..###...........##..##......#..#.......##...#.#.......##.......##..##....#37.......#...##....#.##.....#.#.....#..77......#..#.....#.......###..#.....##.......#.#..#........#..........#..#.....94....##..#.......#.#...#....#...##.#.......##...#..#..#........#.#.##.#.....#...#..........#.#.14.#....##.#....76..#.##.#...#......#...#.#.#....##.#.#.#.##...##........#..#.#.......##...#..44..#......#........................#.#..#.#..56.....#.#.#.#..#...##...##.........##...#.#....##..#.....56.......##.#..#.#......#........##....#.#........##.#...#24......#.#.#....###......63#...#..#......#.##...#.....##.#.......##....#........##.#....##26....#..#...##...###.......73.........###......###...###.....#.#.....#...#......#.....##..........#...31....#.#......##....#.#........#20##..#....##.#.......40#.#......##..#.#...##....##....#....#...11..#.....##.58.##..##..##.#.....#.#.........#.....#........##..##.#....#83..#.#.....###....#......#........#...#...#.........#...#.#.....#..#.##..#.#.#.##.#.10........#.32.#....#....##..#......#...#.#..#79#............##.##..#.#...#......#.#.##......#.#...##..#..#......##.#.#....#..#2#.44.....#...#........##.......#................57...#....##...............#.........#.###.#.....#.##.#.##.9.##......63##.....#....#..##.....#.#.#.#...#..#........#..#........####.#.90..#.....#...###....##.#.##.#.##...........##...........#..#..##...#....#..#....#...#......49##.......#........#.............##.............#.2..30...#.#..#.......#.#....#..#...96....#.#.#........#.............#..##.....##.#......#...#.#..#.#.....##.#.......#......#...#..#..98#.#....#..#..#...#.....#.........##...#.#.#..###..#.#.##......#...#.##...#.#.#.#....##..####..#...90#.##....#.#.#..##......##.#.........#......#.......#..#..##.......#.#..#..............#.#.79.................##.##...#...#............#.......#.....#...#...#..........#...85....##..##....#.#....##....#...#....#.#..###..#...#.....#...........#...#.........#..69...............##.......#.......#.#...............#..#..#.....#..#..#7..#....91.#..................#......#...#....#.......#.#....#......#...##....#.........#....#....#.#9#.##.#.#.5.....48#.....#..#.....#....#..#.##..#.....#..#.........`

Sample Output: (AC code)
Code: Select all
`Case 1: 1Case 2: 3Case 3: 0Case 4: 14Case 5: 13Case 6: 14Case 7: 19Case 8: 26Case 9: 12Case 10: 25Case 11: 29Case 12: 4Case 13: 22Case 14: 14Case 15: 16Case 16: 17Case 17: 7Case 18: 18Case 19: 8Case 20: 21Case 21: 9Case 22: 6Case 23: 12Case 24: 4Case 25: 17Case 26: 25Case 27: 4Case 28: 10Case 29: 23Case 30: 1Case 31: 14Case 32: 17Case 33: 3Case 34: 19Case 35: 26Case 36: 15Case 37: 1Case 38: 9Case 39: 29Case 40: 26Case 41: 28Case 42: 25Case 43: 26Case 44: 22Case 45: 3Case 46: 28Case 47: 3Case 48: 2Case 49: 15`
PromeNabid
New poster

Posts: 21
Joined: Mon Jun 18, 2012 12:52 am