{"trustable":true,"prependHtml":"\u003cstyle\u003e.statText pre { font-size: 12px; }\ntable {display:block !important; width:100%; }\ntable tbody {display:block !important; width:100%; }\ntable tbody tr { width:100% !important;display: block;}\ntable tbody tr td.statText { margin-left: 5px; display: inline-block; width: fit-content; }\ntable tbody tr td.statText br { display: block; content: \" \";line-height: 12px;margin: 12px 0;}\ntable tbody tr td.statText table table pre {\n white-space: pre-wrap;\n text-overflow: ellipsis;\n word-break: break-all;\n}\ntd { padding: 0 !important; border: none !important; }\npre { line-height: normal; margin: 0; }\n\u003c/style\u003e","sections":[{"title":"","value":{"format":"HTML","content":"\n \n \t\t\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u003ch3\u003eProblem Statement\u003c/h3\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eA contest is held between two teams of fighters. The first team is comprised of \u003cb\u003eN\u003c/b\u003e persons and the second is comprised of \u003cb\u003eM\u003c/b\u003e persons. In the course of the contest, each fighter of the first team will confront each fighter of the second team once. To make the contest more entertaining and less protracted, the organizers divided it into several rounds. In each of the rounds, several fights occur simultaneously. Therefore, a fighter may only participate in one fight per round.\u003cbr\u003eThe contest must be divided into the least number of rounds. One can easily see that this number is the maximum between \u003cb\u003eN\u003c/b\u003e and \u003cb\u003eM\u003c/b\u003e. Now the exact schedule of fights must be determined. Return a String[] containing exactly \u003cb\u003eN\u003c/b\u003e elements. Each element of the return must contain exactly \u003cb\u003eM\u003c/b\u003e characters from the set {\u00271\u0027-\u00279\u0027, \u0027A\u0027-\u0027Z\u0027, \u0027a\u0027-\u0027o\u0027}. Letters \u0027A\u0027-\u0027Z\u0027 stand for numbers 10-35 and \u0027a\u0027-\u0027o\u0027 stand for numbers 36-50. The j-th character of element i corresponds to the number of the round in which fighter i of the first team encounters fighter j of the second team. If there are several possible schedules, return the one with the lexicographically least first element. If there still are multiple choices, choose the schedule with the lexicographically least second element, and so on.\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u0026nbsp;\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u003ch3\u003eDefinition\u003c/h3\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003eClass:\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eTheContest\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003eMethod:\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003egetSchedule\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003eParameters:\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eint, int\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003eReturns:\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eString[]\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003eMethod signature:\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eString[] getSchedule(int N, int M)\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e(be sure your method is public)\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u0026nbsp;\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u003ch3\u003eNotes\u003c/h3\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" valign\u003d\"top\" class\u003d\"statText\"\u003e-\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003eA string A is lexicographically less than another string B of the same length if there exists a position i such that each character of A before the i-th position is equal to the character at the corresponding position in B, and A[i] is less than B[i]. When comparing the characters, refer to the following list of characters in ascending order: \u00271\u0027, \u00272\u0027, ..., \u00279\u0027, \u0027A\u0027, \u0027B\u0027, ..., \u0027Z\u0027, \u0027a\u0027, \u0027b\u0027, ..., \u0027o\u0027.\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u0026nbsp;\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u003ch3\u003eConstraints\u003c/h3\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" valign\u003d\"top\" class\u003d\"statText\"\u003e-\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003cb\u003eN\u003c/b\u003e will be between 1 and 50, inclusive.\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" valign\u003d\"top\" class\u003d\"statText\"\u003e-\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003cb\u003eM\u003c/b\u003e will be between 1 and 50, inclusive.\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u0026nbsp;\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003e\u003ch3\u003eExamples\u003c/h3\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" nowrap\u003d\"true\" class\u003d\"statText\"\u003e0)\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e3\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e3\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003eReturns: {\"123\", \"231\", \"312\" }\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003eThere are three persons on each team, so the whole contest is divided into three rounds. If we denote the i-th person of the first team as Ai and the j-th person of the second team as Bj, the fights schedule for each of the rounds is:\u003cbr\u003eRound 1: A1-B1, A2-B3, A3-B2\u003cbr\u003eRound 2: A1-B2, A2-B1, A3-B3\u003cbr\u003eRound 3: A1-B3, A2-B2, A3-B1\u003cbr\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" nowrap\u003d\"true\" class\u003d\"statText\"\u003e1)\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e4\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e4\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003eReturns: {\"1234\", \"2143\", \"3412\", \"4321\" }\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003eThis time, both teams comprise of four persons, so the contest takes 4 rounds to finish.\u003cbr\u003eRound 1: A1-B1, A2-B2, A3-B3, A4-B4\u003cbr\u003eRound 2: A1-B2, A2-B1, A3-B4, A4-B3\u003cbr\u003eRound 3: A1-B3, A2-B4, A3-B1, A4-B2\u003cbr\u003eRound 4: A1-B4, A2-B3, A3-B2, A4-B1\u003cbr\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" nowrap\u003d\"true\" class\u003d\"statText\"\u003e2)\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e4\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e6\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003eReturns: {\"123456\", \"214365\", \"345612\", \"436521\" }\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd colspan\u003d\"2\" class\u003d\"statText\"\u003eThe competition now is held in 6 rounds. Note that since the teams are of unequal size, two of the second team\u0027s fighters are taking rest in each of the rounds.\u003cbr\u003eRound 1: A1-B1, A2-B2, A3-B5, A4-B6\u003cbr\u003eRound 2: A1-B2, A2-B1, A3-B6, A4-B5\u003cbr\u003eRound 3: A1-B3, A2-B4, A3-B1, A4-B2\u003cbr\u003eRound 4: A1-B4, A2-B3, A3-B2, A4-B1\u003cbr\u003eRound 5: A1-B5, A2-B6, A3-B3, A4-B4\u003cbr\u003eRound 6: A1-B6, A2-B5, A3-B4, A4-B3\u003cbr\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" nowrap\u003d\"true\" class\u003d\"statText\"\u003e3)\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e5\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e3\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003eReturns: {\"123\", \"214\", \"345\", \"451\", \"532\" }\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd align\u003d\"center\" nowrap\u003d\"true\" class\u003d\"statText\"\u003e4)\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u0026nbsp;\u0026nbsp;\u0026nbsp;\u0026nbsp;\u003c/td\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003ctable\u003e\u003ctbody\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e28\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003e40\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003cpre\u003eReturns: \n{\"123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcde\",\n\"21436587A9CBEDGFIHKJMLONQPSRUTWVYXaZcbed\",\n\"34127856BC9AFGDEJKHINOLMRSPQVWTUZaXYdebc\",\n\"43218765CBA9GFEDKJIHONMLSRQPWVUTaZYXedcb\",\n\"56781234DEFG9ABCLMNOHIJKTUVWPQRSbcdeXYZa\",\n\"65872143EDGFA9CBMLONIHKJUTWVQPSRcbedYXaZ\",\n\"78563412FGDEBC9ANOLMJKHIVWTURSPQdebcZaXY\",\n\"87654321GFEDCBA9ONMLKJIHWVUTSRQPedcbaZYX\",\n\"9ABCDEFG12345678PQRSTUVWXYZabcdeHIJKLMNO\",\n\"A9CBEDGF21436587QPSRUTWVYXaZcbedIHKJMLON\",\n\"BC9AFGDE34127856RSPQVWTUZaXYdebcJKHINOLM\",\n\"CBA9GFED43218765SRQPWVUTaZYXedcbKJIHONML\",\n\"DEFG9ABC56781234TUVWPQRSbcdeXYZaLMNOHIJK\",\n\"EDGFA9CB65872143UTWVQPSRcbedYXaZMLONIHKJ\",\n\"FGDEBC9A78563412VWTURSPQdebcZaXYNOLMJKHI\",\n\"GFEDCBA987654321WVUTSRQPedcbaZYXONMLKJIH\",\n\"HIJKLMNOPQRSTUVWXYZabcde123456789ABCDEFG\",\n\"IHKJMLONQPSRUTWVYXaZcbed21436587A9CBEDGF\",\n\"JKHINOLMRSPQVWTUZaXYdebc34127856BC9AFGDE\",\n\"KJIHONMLSRQPWVUTaZYXedcb43218765CBA9GFED\",\n\"LMNOHIJKTUVWPQRSbcdeXYZa56781234DEFG9ABC\",\n\"MLONIHKJUTWVQPSRcbedYXaZ65872143EDGFA9CB\",\n\"NOLMJKHIVWTURSPQdebcZaXY78563412FGDEBC9A\",\n\"ONMLKJIHWVUTSRQPedcbaZYX87654321GFEDCBA9\",\n\"PQRSTUVWXYZabcde9ABCDEFGHIJKLMNO12345678\",\n\"QPSRUTWVYXaZcbedA9CBEDGFIHKJMLON21436587\",\n\"RSPQVWTUZaXYdebcBC9AFGDEJKHINOLM34127856\",\n\"SRQPWVUTaZYXedcbCBA9GFEDKJIHONML43218765\" }\u003c/pre\u003e\u003c/td\u003e\u003c/tr\u003e\u003ctr\u003e\u003ctd class\u003d\"statText\"\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/tbody\u003e\u003c/table\u003e\u003chr\u003e\u003cp\u003eThis problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved. \u003c/p\u003e\n \n "}}]}