12405 - Scarecrow

All about problems in Volume CXXIV. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

12405 - Scarecrow

Postby riazur_cse » Sun Jan 08, 2012 4:45 am

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

Postby plamplam » Sun Jan 08, 2012 8:55 am

Code: Select all
8
5
.....
5
..*..
10
....##..#.
10
.....#....
9
....#....
12
....#....#..
10
..#..##...
13
..#..##....#.
You tried your best and you failed miserably. The lesson is 'never try'. -Homer Simpson
User avatar
plamplam
Experienced poster
 
Posts: 151
Joined: Fri May 06, 2011 11:37 am

12405

Postby riazur_cse » Sun Jan 08, 2012 2:26 pm

#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

Postby robot » Tue Jan 10, 2012 9:36 am

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

Postby leobonalume » Mon Jan 16, 2012 8:14 pm

output for plamplam's input

Code: Select all
Case 1: 2
Case 2: 2
Case 3: 4
Case 4: 4
Case 5: 3
Case 6: 4
Case 7: 3
Case 8: 4
leobonalume
New poster
 
Posts: 5
Joined: Mon May 09, 2011 8:49 pm

Re: 12405

Postby PromeNabid » Thu Jun 28, 2012 1:24 pm

Generator by: Jane Alam Jan
http://www.LightOj.com
Sample Input: (By Generator)
Code: Select all
49
3
...
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: 1
Case 2: 3
Case 3: 0
Case 4: 14
Case 5: 13
Case 6: 14
Case 7: 19
Case 8: 26
Case 9: 12
Case 10: 25
Case 11: 29
Case 12: 4
Case 13: 22
Case 14: 14
Case 15: 16
Case 16: 17
Case 17: 7
Case 18: 18
Case 19: 8
Case 20: 21
Case 21: 9
Case 22: 6
Case 23: 12
Case 24: 4
Case 25: 17
Case 26: 25
Case 27: 4
Case 28: 10
Case 29: 23
Case 30: 1
Case 31: 14
Case 32: 17
Case 33: 3
Case 34: 19
Case 35: 26
Case 36: 15
Case 37: 1
Case 38: 9
Case 39: 29
Case 40: 26
Case 41: 28
Case 42: 25
Case 43: 26
Case 44: 22
Case 45: 3
Case 46: 28
Case 47: 3
Case 48: 2
Case 49: 15
PromeNabid
New poster
 
Posts: 17
Joined: Mon Jun 18, 2012 12:52 am
Location: Dhaka, Bangladesh.


Return to Volume CXXIV

Who is online

Users browsing this forum: No registered users and 1 guest