PROBLEM LINK:DIFFICULTY:Cake walk PREREQUISITES:None PROBLEM:You're given an array of houses some of which have a bomb and others don't. These bombs will explode simultaneously and when bomb in i^{th} house explodes, it destroys adjacent houses. Your task is to find out the number of houses which aren't destroyed. QUICK EXPLANATION:For every house check if it is destroyed or not. DETAILED EXPLANATION:There are two almost similar ways of solving this problem. Key idea is to find out for each house if it is destroyed or not. How do we check if i^{th} house will be destroyed or not? It will be destroyed iff at least one of i1, i and i+1^{th} houses have a bomb. Just beware of the boundaries as first and last houses have only one adjacent house. So final solution is :
An alternative solution would be to move over houses with bombs and mark those houses that will explode.
Both of these are O(N) solutions and very comfortably fit in time limit. SETTER'S SOLUTION:Will be uploaded soon. TESTER'S SOLUTION:Can be found here.
This question is marked "community wiki".
asked 11 Aug '12, 15:32

Whats wrong in my code??? Why is it showing NZEC everytime. Some one please help.
import java.io.; import java.util.; class acm {
} } class FasterScanner { private InputStream mIs; private byte[] buf = new byte[1024]; private int curChar; private int numChars;
}
answered 09 Nov '16, 02:09

why is this solution wrong? answered 04 Aug '17, 11:32

I'm getting WA. I don't understand on which test case its failing. Someone please help? link to solution: https://www.codechef.com/viewsolution/16605991 answered 19 Dec '17, 20:16
@mohmum your code fails for 1 1 1 answer should be zero but your code prints 1
(19 Dec '17, 20:38)

Somebody, please tell me where does my program fail? https://www.codechef.com/viewsolution/16606169 answered 19 Dec '17, 20:42

whats wrong in my C code for the problem LEBOMBS https://www.codechef.com/viewsolution/17048802 can anyone tell me on which values my code fails .. Thanks answered 11 Jan, 01:36

include<bits stdc++.h="">using namespace std; int main(){ int t;cin>>t; while(t){ int n;cin>>n;int count=0; string s;cin>>s; if(s[0]=='1'){count+=1;if(s[1]=='0'){s[1]='2';count+=1;}} for(int i=1;i<n1;i++){ if(s[i]="='0's[i]=='2'){continue;}" else{++count;="" if(s[i1]="='0'){count+=1;}" if(s[i+1]="='0'){++count;s[i+1]='2';}" }}if(s[n1]="='1'){count+=1;" if(n="">2){if(s[n2]=='0'&&s[n3]=='0')count+=1;} else if(s[0]=='0')count+=1;} cout<<(ncount)<<endl;} return 0;} What is wrong with the code? answered 27 Feb, 14:58

https://www.codechef.com/viewsolution/17555048 Can anyone help me with this code, please? answered 27 Feb, 15:00

whats wrong in my solution?? \ include<iostream>using namespace std; int main(){ int i,n,t,count; cin>>t; while(t){ count=0; cin>>n; char c[n]; for(i=0;i<n;i++) cin="">>c[i]; if(c[0]=='0'&&c[1]=='0'){ count++; } if(c[n1]=='0'&&c[n2]=='0'){ count++; } for(i=1;i<(n1);i++){ if(c[i]=='0'){ if(c[i1]=='0'&&c[i+1]=='0') count++; } } cout<<count<<endl; } return 0; } answered 04 Jun, 19:28
