Search found 147 matches

Wed Aug 17, 2011 2:18 pm
Forum: Volume 117 (11700-11799)
Topic: 11733 - Airports
Replies: 23
Views: 7510

Re: 11733 - Airports

try this:

Code: Select all

``````1
8 7 10
1 3 5
1 2 8
2 4 6
3 4 10
4 5 30
5 6 6
5 7 15
``````

Code: Select all

``Case #1: 65 4``
Sun Aug 07, 2011 10:10 am
Forum: Volume 109 (10900-10999)
Topic: 10913 - Walking on a Grid
Replies: 23
Views: 12454

Re: 10913 - Walking on a Grid

2 more random cases: 30 5 12 -54 6 4 3 12 54 6 4 3 12 54 6 4 3 12 54 6 4 3 12 -54 6 4 3 -12 -54 6 4 -3 12 -54 6 4 3 12 -54 6 4 3 12 54 6 4 3 12 54 6 4 3 12 -54 6 4 3 -12 -54 6 4 -3 12 -54 6 4 3 12 -54 6 4 3 12 54 -6 4 3 12 54 6 4 3 12 -54 6 4 3 -12 -54 6 4 -3 12 -54 6 4 3 12 534 6 4 3 12 54 6 -4 3 1...
Mon Aug 01, 2011 4:55 pm
Forum: Volume 5 (500-599)
Topic: 540 - Team Queue
Replies: 37
Views: 16231

Re: 540- Team Queue, RTE

I implemented my own queue for this problem using linked list. Its only the 2nd problem in uva that i solved using linked-list,the other one is 112
Fri Jul 15, 2011 1:27 pm
Forum: Volume 116 (11600-11699)
Topic: 11666 - Logarithms
Replies: 16
Views: 6164

Re: 11666 Logarithms WA again and agian

The problem is not that hard,high school math is enough,value of L can be found by linear search as you should see L<=31.

But avoiding precision error is pain. I got wa using long double,got wa using eps. i got ac using double and no eps. find power of e using exp() function.
Fri Jul 15, 2011 1:40 am
Forum: Volume 9 (900-999)
Topic: 944 - Happy Numbers
Replies: 20
Views: 12907

Re: 944 - Happy number

Any permutation of the digits of a happy (unhappy) number must also be happy (unhappy). This follows from the fact that addition is commutative.
This is the most important hint for this problem,use dp and optimize your code using this principle.
Wed Jul 13, 2011 6:44 pm
Forum: Volume 115 (11500-11599)
Topic: 11545 - Avoiding Jungle in the Dark
Replies: 13
Views: 4641

Re: 11545 - Avoiding Jungle in the Dark

consider consecutive asterix's+1 as the distance between the node before 1st asterix and the node after the last asterix. Dont travel at night if distance between two node is greater than 1. Run a bfs with 3states.(current pos,current time,current energy)
Fri Jul 08, 2011 2:39 pm
Forum: Volume 114 (11400-11499)
Topic: 11491 - Erasing and Winning
Replies: 14
Views: 6357

Re: 11491 - Erasing and Winning

The main idea is you will delete a digit d if d[i+1]>d . if there are multiple such d ,than delete the leftmost. if there are no d delete the last digit. Now its upto you,how you will implement the code. I implemented using a queue. I got tle using stl,than used simple array and got ac. to pop from ...
Wed Jul 06, 2011 10:49 pm
Forum: Volume 107 (10700-10799)
Topic: 10754 - Fantastic Sequence
Replies: 16
Views: 11076

Re: 10754 - Fantastic Sequence

Nice problem (it was a tougher one for me).

I used this mod function for handling negative numbers:

Code: Select all

``````i64 mod(i64 a,i64 m)
{
if(a>0) return a%m;
if(a==0) return 0;
a=a*-1;
i64 M=a%m;
if(M==0) return 0;
return m-M;
}``````
Mon Jul 04, 2011 8:33 pm
Forum: Volume 102 (10200-10299)
Topic: 10277 - Boastin' Red Socks
Replies: 8
Views: 5073

Re: 10277 - Boastin' Red Socks

After 10wa,2tle,and plenty of hours,finally got accepted. I would like to share some little hints. From basic concept of probability we can easily see R/(R+B)*(R-1)/(R+B-1)=p/q; ==>R*(R-1)/(R+B)*(R+B-1)=p/q; Now make the upper portion of the both fractions same and so you will get (R+B)*(R+B-1)=C wh...
Wed Jun 29, 2011 6:24 pm
Forum: Volume 109 (10900-10999)
Topic: 10911 - Forming Quiz Teams
Replies: 33
Views: 32113

Re: 10911 - Forming Quiz Teams

Why you need a queue? Pick two person(i,j),set corresponding bit and recursively find d[j]+call(mask).
Sun Jun 26, 2011 8:48 pm
Forum: Volume 119 (11900-11999)
Topic: 11935 - Through the Desert
Replies: 10
Views: 4742

Re: 11935 - Through the Desert

SImple Binary Search:
For 300 iterations:
[
volume=(high+low)/2.0
ret=simulate(volume)
if(ret==NOT ENOUGH) low=volume
]
Sun Jun 26, 2011 6:17 pm
Forum: Volume 120 (12000-12099)
Topic: 12032 - The Monkey and the Oiled Bamboo
Replies: 23
Views: 7000

12032 - The Monkey and the Oiled Bamboo

Here are some test case for those who are getting wa: 5 6 1 6 10 14 20 30 10 10 20 30 45 60 75 100 234 4546 45666 3 5 10 15 5 10 20 31 41 51 6 1 2 3 10 20 30 output: Case 1: 10 Case 2: 41120 Case 3: 6 Case 4: 12 Case 5: 11 But the judge data should contain more tricky cases. I got wa trying to solve...
Sun Jun 26, 2011 2:55 pm
Forum: Volume 108 (10800-10899)
Topic: 10891 - Game of Sum
Replies: 33
Views: 12763

Re: 10891 - Game of Sum

Nice problem . Take a number and call the recursive function for rest of the array. A will try to maximize the difference,B will do the opposite. I used 3state dp.
Fri Jun 24, 2011 2:04 pm
Forum: Volume 112 (11200-11299)
Topic: 11286 - Conformity
Replies: 19
Views: 8928

Re: 11286 - Conformity

Read the data as strings,sort them,concatanate them placing separators in middle. than use map. simple
Fri Jun 24, 2011 1:39 pm
Forum: Volume 1 (100-199)
Topic: 153 - Permalex
Replies: 32
Views: 13034

Re: 153

Its easier to write the whole thing in java bigint than trying to optimize the intermediate calculation. some io:

Code: Select all

``````sdfretf
gggfrtttereee
dfffrrrdfdf
zzffffferrrre
aaseajwelrkjlsdj
ewrwerjwelrjwe
#``````
output:

Code: Select all

``````     1826
1801379
1130
535920
1468380809
3265624
``````