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

Common Board

look inside
Posted by King Without Kingdom 8 Apr 2004 03:26
i want to exit from my brute force program after 3 (for example)seconds from its start.Give me please an example of code in С/C++ that will help me.
Re: look inside
Posted by Vesper 21 Apr 2004 19:12
Grab the timer interrupt and set global flag in your calculations. After 3 seconds drop the flag by your interrupt handler and quit the main program. And do not forget to restore interrupt vector.
Not very universal, but oftenly help.
Posted by ronobe (aka oberon) 21 Apr 2004 20:04
Calculate amount of iterations in your brute force cycle.
If IT - (amount of iterations) exceed maximum value which is set by hands and individually, you just stop bruteforcing.
You can set MaxIT = 1 million. If it gets WA in 0.4 second, then you can increase MaxIT twice. Hope this clear.