You are not logged in. Please login at www.codechef.com to post your questions!

×

# adakng Problem

 1 1 // Can some one please look into my code snippet for the ADAKNG Problem // and point out why my code is not accepted . The code is in C++ //Thank you. #include using namespace std; int main() { int t,r,c,k; int y; int dr,ur,fc,bc; / dr = lower_most_row ur = upper_most_row fc = right_most_column bc = left_most_column / int no_of_squares; `dr = 0; fc = 0; ur = 8; bc = 8; cin>>t; while(t--) { cin>>r>>c>>k; for(y=k;y>=0;y--) { if( (1 <= (r+y)) && ((r+y) <= 8) )//if the row exists if((r+y) > dr)// if the new value is lower than current row dr = (r+y); if( (1 <= (r-y)) && ((r-y) <= 8) )// if the row exists if((r-y) < ur)// if the new value is higher than current row ur = (r-y); if( (1 <= (c+y)) && ((c+y) <= 8) )//if the column exists if((c+y) > fc)// if the new value is more right than current column fc = (c+y); if((1 <= (c-y)) && ((c-y) <= 8))//if the column exists if((c-y) < bc)// if the new value is more left than current column bc = (c-y); } no_of_squares = (dr - ur + 1) * (fc - bc + 1); cout<

One Answer:
 4 One mistake that I found is that you have initialised dr, ur, fc, bc outside the t loop. They need to be reinitialised everytime for different test cases. Fix this. If it still doesn't work and there are more errors, comment below and I'll try to find them. Hope this helps :) answered 05 Feb, 02:56 865●2●14 accept rate: 10% 1 Thank you Akash. Your Suggestion really worked out. (06 Feb, 18:13)
 toggle preview community wiki:
Preview

### Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• link:[text](http://url.com/ "title")
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×20

question asked: 04 Feb, 23:07

question was seen: 93 times

last updated: 06 Feb, 18:13