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 1476. Lunar Code

WA #7
Posted by Deepesson 2 Jan 2021 00:01
The 7th test case is:
2 5 1

And my program outputs 348.
I've tried to brute-force, and I got the same result. Did I misunderstand the problem?
What should be the output for this test case?
Re: WA #7
Posted by Deepesson 2 Jan 2021 00:05
Ok, the answer is 780, but I don't know why.
Re: WA #7
Posted by Deepesson 2 Jan 2021 00:25
Ok, I'm stupid.
Here's a function that checks if a matrix respects the Lunar Condition.
bool lunar_check() {
    for(int i = 0; i != N-1;++i) {
        int count = 0;
        for(int j = 0; j != M;++j) {
            count += (matrix[j][i]==0&&matrix[j][i+1]==1);
        }
        if(count>K) return false;
    }
    return true;
}
I hope that nobody else's have problems reading the statement. ;-;