ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1005. Stone Pile

Hint
Posted by Pastafarianist 19 Nov 2011 21:59
This problem can be solved using brute force. The asymptotics is O(n*2^n) but still the time limit is not hit, provided you use bit operations instead of generating arrays. For you beginners, I post my code here, but I strongly recommend to write this on your own first. The language I use is Java; nextInt() function returns the next integer from the input.

[code deleted]

Worst time is 0.187 sec, as reported by Timus.

Edited by moderator 21.10.2019 22:59
Re: Hint
Posted by Milena Araujo 22 Nov 2011 01:17
Hi !
Would you mind explaining the if on the second for ?
I mean, how is this putting all different combination of blocks on each pile ?
Thanks :D
Re: Hint
Posted by Frankie 29 Nov 2011 15:12
man u're awesome :) solution is great for that kinda bruteforce! just made all those things in cpp myself and got ACd :D

but this problem's still far too hard for the "beginners" tag on which it is right now :)
Re: Hint
Posted by IlushaMax 28 Mar 2016 16:54
Can anybody translate me this code on C++ or Pascal
Re: Hint
Posted by Shah Habibul Imran 17 Oct 2018 20:09
Thanks, got AC converting it into C++.