![]() |
Quote:
|
I think it's slow because of the logging you're doing. But yeah, quite some loops also.
|
Oh it's only 50? :P
Time remaining: 0.007151126 Still crappy. :P I took out the log too. |
We can assume that the algorithm would eventually need to be used to find an appropriate room assignment for a group of students for which there is only one solution (i.e. worst case scenario). Because of this, the algorithm would need to "know" that student A needs to pair with student B rather than student C. Hence why random is a horrible idea.
|
PHP Code:
Should run in O(n log n log m) where n is the number of pairs and m is the number of bad pairs. |
I realized I made an error, but it wouldn't let me edit it... so here is another giant block of code:
PHP Code:
|
Quote:
answer: http://img376.imageshack.us/img376/5436/86884629uj9.png http://img376.imageshack.us/img376/5...101aefdfeb.jpg proof: N and B are disjoint sets. (see above picture) --- this is an abstract problem. idk what you guys have been doing with all of that prime number crap. |
This problem is NP-complete, so it's impossible to do it in polynomial time.
The runtime is actually O(n**m) if you check all conditions. The best way to attack the problem would most likely be dynamic programming. |
All times are GMT +2. The time now is 09:42 AM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.