Friday, March 27, 2020

UVa - 10662 - The Wedding

Link to pdf on UVa OJ

In the middle of reading the problem I thought I may need to use some kind of backtracking or dynamic programming, but when I saw the constraints it was obvious I need to do nested for loops in order to solve it. Three nested for loops will do the job.
Here we only have travel agency, restaurant and hotels, if this number increases or it is not a static number we have to use recursion to check all combinations.
I solved it using recursion as well. Take a look at my code for the details.

1 - My iterative solution on github
2 - My recursion solution on github



No comments:

Post a Comment

USACO - Prime Palindromes

I just skimmed the problem statement and panicked of the high boundary of the input, but something inside told me don't worry everyth...