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 1507. Difficult Decision

This problem is quite funny.
Posted by 198808xc 2 Oct 2010 18:32
Though I have realized there might be some math-method to solve the problem, I couldn't find them out. So, I just solve the problem "the way it tells me to do".

To prevent high-precision (Chinese name of long-arithmetic), I use this method: I choose many factors and calculate the power of the matrix with the module of the factors. So, if one cell is 0 under all the factors, we can ALMOST assert that the cell is indeed 0.

To prevent TLE, the factors could not be so many: I choose 10 factors first, that is 16384 (2^15), 19683 (3^9), 15625 (5^6), ... until 24389 (29^3). My program runs well but get TLE @ test 17.

So, I decrease the factors to only TWO: 16384 and 19683. This time my program get WA @ 9! I think I really appreciate the author for so good test-data.

After that I increase my factors to 4, adding 15625 and 16807. This time I got AC in 0.64s.

Funny problem, thx to the author.
Have fun and good luck.
Re: This problem is quite funny.
Posted by Moonstone [Samara SAU] 3 Oct 2010 02:08
Hehe, you're CRAZY man...
I just used boolean matrix.

Edited by author 03.10.2010 02:10
What does boolean matrix mean?
Posted by 198808xc 6 Oct 2010 22:08
Well, before I decided to use this CRAZY method, I have read all the topics on board, but I still can't understand the meaning of BOOLEAN MATRIX.

Could you or anyone explain it to me?
Re: What does boolean matrix mean?
Posted by Moonstone [Samara SAU] 6 Oct 2010 22:18
Input: a[i][j] = readInt() > 0;

Then use && instead of * and || instead of +.

If result contains at least one false value, write "No".

P.S. I don't believe my eyes! You have 400+ problems solved and couldn't guess this simple approach!

Edited by author 06.10.2010 22:22
Re: What does boolean matrix mean?
Posted by 198808xc 11 Oct 2010 00:34
Well, just after reading your post, I read the problem statement again.
I found that I had ignored the fact that all the number is non-negative. (So stupid mistake)

Thank you.