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 1155. Troubleduons

Burunduk1 Is it right? [5] // Problem 1155. Troubleduons 9 May 2005 12:23
My solution:
1. (A+C+F+H)-(B+D+E+G)=const => if const!=0 then IMPOSSIBLE
2. While we have to destroy some we do two operations. (3,4)
   3. If we can do one of (AB, BC, CD, DA, EF, FG, GH, HE, AE, BF, CG, DH)- we do it.
   4. If AG => BF+ AB- GF-
      If BH => CG+ BC- HG-
      If CE => DH+ CD- EH-
      If DF => AE+ DA- FE-

Why it gets WA #5?
Is it wrong algorithm or wrong realization?

My code:

Here was nearly AC code :)

Edited by author 30.05.2005 05:31
Burunduk1 Or give me some tests [1] // Problem 1155. Troubleduons 10 May 2005 15:09
bug27 Re: Or give me some tests // Problem 1155. Troubleduons 10 May 2005 17:17
though I don't know what "2. While we have to destroy some we do two operations. (3,4)" mean, I think you solution is right,because I got AC in the same way.maybe there's some bugs in your code.
Dilyan not perfectly [2] // Problem 1155. Troubleduons 13 May 2005 23:30
2, 3 and 4 are right.
1 is wrong. const may be different from 0 when there is a solution
Burunduk1 Re: not perfectly [1] // Problem 1155. Troubleduons 14 May 2005 02:43
Are you sure? Can you give me example?

I can prove it:
We process operation with pair of vertexes.
The one is in {A,C,F,H} another is in {B,D,E,G}.
So (A+C+F+H)-(B+D+E+G)=const
Supose we already annighilated all 'troubles' then
A=B=C=D=E=F=G=H=0 => const=0 =>
If const is not equal to zero we can't annighilate all 'troubles' => IMPOSSIBLE

What is wrong in it?
Burunduk1 Now it is AC // Problem 1155. Troubleduons 30 May 2005 05:29
Algorithm is Ok, but in my code was one misprint.