Page 1 of 2
11111 - Generalized Matrioshkas
Posted: Sun Oct 08, 2006 7:33 pm
by fcsc
Everytime that i read the problem i get more confused, can somebody explain it to me?
Thanks
Posted: Sun Oct 08, 2006 7:50 pm
by arsalan_mousavian
as the problem statement is too long,i haven't read the problem statement Completely during the Contest,
consider you have some boxes that some of them are nested in some other boxes , each box should begin with negative number and end with the absolute value of that negative number , the absolute value shows the size of box , and the sum of size of inside boxes should be less than the outside boxes , you are given sequence of the numbers , you should check whether it violates the above rules or not, that's all
Hope it helps
Posted: Mon Oct 09, 2006 12:24 pm
by Tariq Shahriar
To clear more , consider the following input:
this is a invalid input; -8 8 -5 5 is surrounded by -10 10 and 8+5=13 sized box cannot be allocated in a 10 sized box. but above input can be validated in this way-
Now it is possible. because, if the 5 sized box is placed in 8 sized box then it allocated in the 10 sized box easily. now see the picture below. fig 1 is for input 1 and fig 2 for input 2.
But i got wa in this problem(?). i used stack of stl and a lot of checks.
i also checked on with this input:
Code: Select all
-9 -7 -2 2 -3 -2 -1 1 2 3 7 9
-9 -7 -2 2 -3 -1 -2 2 1 3 7 9
-9 -7 -2 2 -3 -1 -2 3 2 1 7 9
-100 -50 -6 6 50 100
-100 -50 -6 6 45 100
-10 -5 -2 2 5 -4 -3 3 4 10
-9 -5 -2 2 5 -4 -3 3 4 9
-10 -5 -3 3 -1 1 5 -4 4 10
10
-10 10
-10
my output is:
Code: Select all
:-) Matrioshka!
:-( Try again.
:-( Try again.
:-) Matrioshka!
:-( Try again.
:-) Matrioshka!
:-( Try again.
:-) Matrioshka!
:-( Try again.
:-) Matrioshka!
:-( Try again.
I inputed char wise and escaped the blank lines of the input.
Kindly any body helps me by giving more input.
Posted: Mon Oct 09, 2006 6:59 pm
by Wei-Ming Chen
I also got WA many times on this problem
It needed many details to solve the problem, and my code fell on these
The correct answers are easy to know
Hope it helps
Posted: Mon Oct 09, 2006 10:16 pm
by asif_rahman0
I dont solve this problem, yet. But i think for your input, output should be:
Posted: Tue Oct 10, 2006 3:53 am
by Tariq Shahriar
Wei-Ming Chen wrote:
and my code fell on these
Wei-Ming Chen, i can understand the problem of your code.
you think the line of input as stack. when a positive number(let x) is inputed, then check that-
if(stack_size!=0 && top_of_stack == x ) pop the top num;
else print "try again".
My program generated correct output for your input.
please any one post more input.
Posted: Tue Oct 10, 2006 8:09 am
by asif_rahman0
input:
Code: Select all
-9 -7 7 -2 2 9
-9 -2 2 -1 1 -6 6 9
-9 -2 2 -1 -5 5 1 9
-9 -2 2 -1 1 -2 5 9
-9 -2 2 -1 1 -1 1 9
Output:
Code: Select all
:-( Try again.
:-( Try again.
:-( Try again.
:-( Try again.
:-) Matrioshka!
Posted: Tue Oct 10, 2006 5:32 pm
by Wei-Ming Chen
Code: Select all
-200 -180 -50 50 -60 60 -69 -50 -40 40 50 -11 11 69 180 200
-3 -1 1 -1 1 3
-3 -1 -1 1 1 3
-50 -20 20 -15 15
-8 7 -7 8
-60 -55 -53 -6 6 -12 12 -40 40 53 55 60
Code: Select all
:-) Matrioshka!
:-) Matrioshka!
:-( Try again.
:-( Try again.
:-( Try again.
:-( Try again.
Hope it helps.
Posted: Tue Oct 10, 2006 9:41 pm
by StanleY Yelnats
my o(n) solution using stacks exceeds the time limit,
is there any faster aproach or there is something wrong about my code?
Posted: Wed Oct 11, 2006 1:49 am
by sclo
StanleY Yelnats wrote:my o(n) solution using stacks exceeds the time limit,
is there any faster aproach or there is something wrong about my code?
Something is wrong about your code. My O(n) solution using recursion runs in time, and using stack is always faster than recursion. Probably your code has infinite loop.
Posted: Wed Oct 11, 2006 8:31 am
by Tariq Shahriar
Thanks Wei-Ming Chen.
my code would fail in your this test case -3 -1 -1 1 1 3 for improper checking.
Now ac in 244 millisec.
Posted: Wed Oct 11, 2006 8:58 am
by StanleY Yelnats
what's the correct output for this :
Posted: Wed Oct 11, 2006 9:07 am
by Tariq Shahriar
Obviously
(from my ac code)
Posted: Sun Nov 12, 2006 8:45 am
by helloneo
Hello..~
I don't clearly understand this problem..
Please tell me what the correct output is for this input..
Thanks..

Posted: Sun Nov 12, 2006 9:30 am
by rio