Editorial for this problem seems to be resulting an unnecessarly
complicated code.
Solution is O(R*S) and 15 LOC (python 3). [I missed it during the contest
"of course", as I spent much time on the interactive problem.]
The idea is same but it is easy to prove that resulting sizes for A and B
can be calculated by the fact, that one [actually the first]
2-difference-cancelling move is: A ends before the 3rd rank appears, and
the last card in B is always increased by 2, starting with R+1. End of A
can be calculated by just maintaining the longest same-rank so far for all
ranks.
Special case is the same [ending B for the last is R*S-2, not R*S-1], but
no need to count, it's always R-1, (S-1)*R.

Axioma / Kata





spoiler alert








-----
T = int(input())
for tst in range(T):
    R, S = map(int, input().split())
    nums=[1]*R
    i=0
    todo=R*(S-1)
    print("Case #" + str(tst + 1) + ": " + str((todo+1)//2))
    for lst in range(R+1,R*S,2):
        fst=nums[i]+nums[(i+1)%R]
        print(fst,lst-fst)
        nums[i]+=1
        nums[(i+1)%R]+=1
        i=(i+2)%R
    if lst==R*S-2:
        print(S-1,(R-1)*S)

'Samantha' via Google Code Jam <[email protected]> ezt írta
(időpont: 2020. ápr. 18., Szo 1:28):

> Hello,
>
> The time has come — the next chance to participate in Code Jam Round 1
> begins in under 48 hours with Round 1B! Visit the schedule page
> <https://codingcompetitions.withgoogle.com/codejam/schedule> to see
> rounds in your browser's local time zone and to add events to your
> calendar. *All posting on this group will be paused during all Code Jam
> online rounds.*
>
> *Important Reminders:*
>
>    - Round 1 is divided into two more sub-rounds (1B and 1C). Each lasts
>    for two hours and thirty minutes. You may compete in as many of the
>    sub-rounds as you want, but if you place in the top 1500 in any sub-round,
>    you'll qualify for Round 2 and won't be eligible to compete in any later
>    sub-rounds
>    - Round results will not be immediately finalized when the round is
>    over. You'll be notified of your advancement status to Round 2 at least one
>    day before that round in the "Alerts" section of the competition website
>    and by email.
>    - *Unlike in the Qualification Round, collaboration is strictly
>    prohibited in Round 1 and all future rounds of Code Jam 2020.* Section
>    7 of the Code Jam Terms
>    <https://codingcompetitions.withgoogle.com/codejam/rulesandterms>
>    prohibits sharing or using from others any information about a problem
>    before the end of the round. Such actions that violate those Terms &
>    Conditions will result in your disqualification. *Moreover, please
>    note that if you are utilizing a web integrated development environment
>    (IDE), be sure to not publish your code or otherwise allow it to be
>    publicly visible during the contest, or you could be subject to
>    disqualification.*
>
> If you have any questions, start by reviewing the FAQs
> <https://codingcompetitions.withgoogle.com/codejam/faq> and Rules and
> Terms <https://codingcompetitions.withgoogle.com/codejam/rulesandterms>. If
> you have questions during the round, use the "Ask a Question" feature in
> the competition interface.
> Good luck to all of those who have advanced and are participating!
> -The Code Jam Team
>
> --
> You received this message because you are subscribed to the Google Groups
> "Google Code Jam" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/google-code/e9bf2dd5-c5e3-4e87-9870-13b79a742b80%40googlegroups.com
> <https://groups.google.com/d/msgid/google-code/e9bf2dd5-c5e3-4e87-9870-13b79a742b80%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/CAPOU4JPgY73V_FCNGAb3dY46%2BK9H8TJgJRLKESd17Y2oH3v6kA%40mail.gmail.com.

Reply via email to