Bob just got an internship writing a graphics driver for a computer screen! The screen can be represented as an -pixel-high by -pixel-wide grid of square pixels, all the same size. Pixel coordinates range from in the bottom-left to in the top-right.
Bob's first task is to display a diagonal line across the screen. More specifically, if you imagine a straight line going from the bottom-left to the top-right corner of the screen, Bob needs to light up all the pixels touching that line. The line must fully intersect a pixel for it to be lit up; pixels that only touch the line at a corner should not be lit.
For example, if and , he should light up the pixels like this (yellow for lit, black for unlit):
Bob needs to know exactly which pixels should be lit. Please help him out so he doesn't get fired!
Constraints
Subtask 1 [20%]
Subtask 2 [80%]
Input Specification
Two space-separated integers, and .
Output Specification
On the first line, print , the total number of pixels that should be lit.
Then on the next lines, print and , the coordinates (row and column) of the lit pixel. Pixels with lower should be printed first. If there is still a tie, print pixels with lower first.
Sample Input
6 10
Sample Output
14
1 1
1 2
2 2
2 3
2 4
3 4
3 5
4 6
4 7
5 7
5 8
5 9
6 9
6 10
Comments
why i am not able to see other coders code ?
You need to solve the problem before you can see other's code.
The only thing I can say, precision errors are the worst. I wrote dda based solution and didn't able to figure out what was wrong, but now after dozens of wrong submissions, it turns out that it was a precision error.
The only thing I can say, compiler errors are the worst. I wrote a c++ solution and wasn't able to figure out what as wrong, but after a dozen wrong submissions, it turns out it was a compiler error because I submitted in Java.
The only thing I can say, kevinyang is the worst. I wrote a comment to him on DMOJ and wasn't able to figure out what was wrong, but after a dozen of wrong comments, it turns out it was a kevinyang problem because I didn't post the comment.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
This comment is hidden due to too much negative feedback. Show it anyway.
(A heads up for c++ users)
I am a c++ user. I took an approach to https://dmoj.ca/problem/aplusb which was really similar to the editorial. However, a very small mistake of using the subtraction symbol instead of the addition symbol costed me to lose points. Correct: a+b. Wrong: a-b. Really ridiculous in my opinion but I guess it is a precision thing.
Full correct submission: https://dmoj.ca/submission/3590927
Full incorrect submission: https://dmoj.ca/submission/3590928
orz
ok
get gud
Your code was wrong so you don't get AC. Please tell me what's ridiculous about it, should the judge just let anything get AC? If that you fancy that, please check out https://dmoj.ca/problem/acc6p9.