Page 1 of 1
11532 - Simple Adjacency Maximization
Posted: Fri Jan 09, 2009 6:48 pm
by saiful_sust
I try to solve this problem
But i get WA.......
can any one help me????????
Code: Select all
CUT after acc..........................
Re: 11532 - Simple Adjacency Maximization
Posted: Fri Jan 09, 2009 8:24 pm
by helloneo
Try some test cases..
My output is..
Re: 11532 - Simple Adjacency Maximization
Posted: Sat Jan 10, 2009 11:52 am
by saiful_sust
Re: 11532 - Simple Adjacency Maximization
Posted: Fri Jan 16, 2009 2:32 pm
by f74956227
I think this problem can be solved by using DP, but i can't find the recursive relationship...
could someone give me a hint?
Re: 11532 - Simple Adjacency Maximization
Posted: Fri Jan 16, 2009 3:36 pm
by helloneo
f74956227 wrote:I think this problem can be solved by using DP, but i can't find the recursive relationship...
could someone give me a hint?
I didn't solve this problem with DP.. Just try to find a pattern..
If there are enough '0's, the best representation would be like this..
...000000101101101101
If there are not enough '0's, you have to insert '0' in smarter way..

Re: 11532 - Simple Adjacency Maximization
Posted: Sat Jan 17, 2009 11:28 am
by f74956227
I got AC!!! It is just a simple simulation problem

Thank!
Re: 11532 - Simple Adjacency Maximization
Posted: Sun Apr 26, 2009 8:49 pm
by aliahmed
ACC
It was wrong for 3 1
Re: 11532 - Simple Adjacency Maximization
Posted: Mon Apr 27, 2009 4:52 pm
by helloneo
I think you might get a precision error here..
Do not use floating point operation
Remove your code after AC

Re: 11532 - Simple Adjacency Maximization
Posted: Sun Jul 05, 2009 1:51 pm
by tryit1
The number of 1s adjacent to one or more 0 in the binary representation is maximized.
What does this mean ? Why isn't 0101011 (43) better than 0101101 (45) in case of 4 3 .
Also i don't understand in case 3 2 , why is it 1101 (13) instead of 10101(21) ?
Re: 11532 - Simple Adjacency Maximization
Posted: Tue Jul 07, 2009 3:37 pm
by helloneo
43 -> 0
10
10
11 has three '1's which are adjacent to '0'
45 -> 0
10
110
1 has four '1's which are adjacent to '0'
So, 45 is better than 43
For input
3 2
1101 and 10101 both have three '1's adjacent to '0'
But, problem statements say that
Find the smallest integer N ..
So, the answer would be 13 (1101)