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 1128. Partition into Groups

Tests must be improved
Posted by raggzy 24 Nov 2013 22:00
The next 2^N worst-case algo gets AC.

searchSolution(i) {
   if (i==N+1) {
       throw new FoundException();
   }
   group[i] = 1;
   if (checkThisAndAdvsHasNotMoreThan1Adv(i)) {
      searchSolution(i+1);
   }
   group[i] = 2;
   if (checkThisAndAdvsHasNotMoreThan1Adv(i)) {
       searchSolution(i+1);
   }
   group[i] = 0;
}

............

try {
   searchSolution(1);
} catch (FoundException e) {
   outputResult();
}
output("NO SOLUTION");


Judges, please do something with it :)
This is cool graph problem, i think in order to get AC one should write O(N) solution :)
But this obvious brute-force gets AC
SAD :(