{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n div.illustration {\n float: right;\n padding-left: 20px;\n }\n div.illustration .illustration {\n width: 100%;\n border-radius: 4px;\n }\n pre {\n display: block;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n color: #333;\n word-break: break-all;\n word-wrap: break-word;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cdiv style\u003d\"width:30.00%\" class\u003d\"illustration\"\u003e\n \u003cimg src\u003d\"CDN_BASE_URL/b4f9627cbf36fa40842263a14a2a75e7?v\u003d1715775468\" alt\u003d\"/problems/bingoties/file/statement/en/img-0001.jpg\" class\u003d\"illustration\"\u003e\n \n \u003c/div\u003e\n \u003cp\u003eBingo is a game of chance played by a group of players. Each\n player has his or her own bingo card with a \u003cspan class\u003d\"tex2jax_process\"\u003e$5$\u003c/span\u003e-by-\u003cspan class\u003d\"tex2jax_process\"\u003e$5$\u003c/span\u003e grid of numbers. Each number\n appears at most once per card. The bingo caller calls out a\n sequence of randomly drawn numbers, and the players mark the\n numbers that appear on their card as they are called out. The\n winner is the player that completes a line of five marked\n numbers (horizontally, vertically or diagonally) on his or her\n card. The winning player then yells “bingo” and the game\n ends.\u003c/p\u003e\n \u003cp\u003eYou have been volunteering with a local youth group and have\n been running bingo games for the children. They love bingo, but\n every time two or more kids yell “bingo” at the same time, a\n spirited “disagreement” breaks out. You’ve created a slightly\n modified version of bingo (in the hopes of introducing fewer\n ties): the cards are \u003cspan class\u003d\"tex2jax_process\"\u003e$5$\u003c/span\u003e-by-\u003cspan class\u003d\"tex2jax_process\"\u003e$5$\u003c/span\u003e grids with a number from\n \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e to \u003cspan class\u003d\"tex2jax_process\"\u003e$3\\, 000$\u003c/span\u003e in each of the \u003cspan class\u003d\"tex2jax_process\"\u003e$25$\u003c/span\u003e cells, and a winner is only\n declared when a player has \u003cspan class\u003d\"tex2jax_process\"\u003e$5$\u003c/span\u003e numbers in a row. Note that in\n this new game, players \u003cb class\u003d\"bfseries\"\u003ecannot win via\n columns or diagonals\u003c/b\u003e.\u003c/p\u003e\n \u003cp\u003eAlas, these changes did not eliminate ties or the subsequent\n disagreements. To prevent further disagreements, you’ve decided\n to analyze the sets of cards to determine if there is any\n possibility that a tie (where two kids can yell bingo at the\n same time) can occur. Write a program that takes a collection\n of bingo cards and determines if there is any possible sequence\n of numbers that could be called so that the game ends, and a\n tie between two or more players occurs, when the last number in\n the sequence is called.\u003c/p\u003e\n \u003cp\u003eFor example, consider the following two bingo cards:\u003c/p\u003e\n \u003ccenter\u003e\n \u003ctable cellspacing\u003d\"0\" class\u003d\"tabular\"\u003e\n \u003ctbody\u003e\u003ctr\u003e\n \u003ctd style\u003d\"border-top-style:solid; border-bottom-style:solid; border-bottom-width:1px; border-left:1px solid black; border-right:1px solid black; border-top-color:black; border-top-width:1px; border-bottom-color:black; text-align:center\"\u003e\n \u003cp\u003e\u003cspan class\u003d\"tex2jax_process\"\u003e$ \\begin{array}{ccccc}\n 3 \u0026amp; 29 \u0026amp; 45 \u0026amp; 56 \u0026amp; 68 \\\\ 1 \u0026amp; 19\n \u0026amp; 43 \u0026amp; 50 \u0026amp; 72 \\\\ 11 \u0026amp; 25 \u0026amp; 40\n \u0026amp; 49 \u0026amp; 61 \\\\ 9 \u0026amp; 23 \u0026amp; 31 \u0026amp; 58 \u0026amp;\n 63 \\\\ 4 \u0026amp; 27 \u0026amp; 42 \u0026amp; 54 \u0026amp; 71 \\end{array}\n $\u003c/span\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd style\u003d\"text-align:center; border-right:1px solid black\"\u003e\n \u003cp\u003e\u0026nbsp;\u003c/p\u003e\n \u003c/td\u003e\n \u003ctd style\u003d\"border-top-style:solid; border-bottom-style:solid; border-bottom-width:1px; border-bottom-color:black; border-right:1px solid black; border-top-color:black; border-top-width:1px; text-align:center\"\u003e\n \u003cp\u003e\u003cspan class\u003d\"tex2jax_process\"\u003e$ \\begin{array}{ccccc}\n 14 \u0026amp; 23 \u0026amp; 39 \u0026amp; 59 \u0026amp; 63 \\\\ 8 \u0026amp; 17\n \u0026amp; 35 \u0026amp; 55 \u0026amp; 61 \\\\ 15 \u0026amp; 26 \u0026amp; 42\n \u0026amp; 53 \u0026amp; 71 \\\\ 10 \u0026amp; 25 \u0026amp; 31 \u0026amp; 57\n \u0026amp; 64 \\\\ 6 \u0026amp; 20 \u0026amp; 44 \u0026amp; 52 \u0026amp; 68 \\\\\n \\end{array} $\u003c/span\u003e\u003c/p\u003e\n \u003c/td\u003e\n \u003c/tr\u003e\n \u003c/tbody\u003e\u003c/table\u003e\n \u003c/center\u003e\n \u003cp\u003eThen this set of two cards could result in a tie if the\n sequence of numbers called was\u003c/p\u003e\u003cspan class\u003d\"tex2jax_process\"\u003e\\[ 40~ 61~ 64~ 10~ 57~ 49~ 11~ 31~ 25\n \\]\u003c/span\u003e\n \u003cp\u003eThis sequence would result in the card on the left\n completing the third row and the card on the right completing\n the fourth row when the number \u003cspan class\u003d\"tex2jax_process\"\u003e$25$\u003c/span\u003e is called.\u003c/p\u003e\n \u003ch2\u003eInput\u003c/h2\u003e\n \u003cp\u003eThe first line of the input is an integer \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$2\n \\leq n \\leq 100$\u003c/span\u003e), the number of bingo cards. After the\n first line are the \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e\n bingo cards, each separated from the next by a blank line of\n input.\u003c/p\u003e\n \u003cp\u003eEach bingo card consists of five lines of input. Each line\n consists of five integers in the range from \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e to \u003cspan class\u003d\"tex2jax_process\"\u003e$3\\, 000$\u003c/span\u003e. The numbers on each bingo\n card are unique.\u003c/p\u003e\n \u003ch2\u003eOutput\u003c/h2\u003e\n \u003cp\u003eIf no ties are possible between any two cards, output\n “\u003ctt class\u003d\"ttfamily\"\u003eno ties\u003c/tt\u003e”. Otherwise, output the two\n numbers \u003cspan class\u003d\"tex2jax_process\"\u003e$a$\u003c/span\u003e and\n \u003cspan class\u003d\"tex2jax_process\"\u003e$b$\u003c/span\u003e (\u003cspan class\u003d\"tex2jax_process\"\u003e$1 \\le a \u0026lt; b \\le n$\u003c/span\u003e) identifying\n the two cards for which a tie could occur, where the cards are\n numbered from \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e to\n \u003cspan class\u003d\"tex2jax_process\"\u003e$n$\u003c/span\u003e in the order that they\n appear in the input. If multiple pairs of cards can tie, output\n the pair with the smallest \u003cspan class\u003d\"tex2jax_process\"\u003e$a$\u003c/span\u003e, breaking any remaining ties with\n the smallest \u003cspan class\u003d\"tex2jax_process\"\u003e$b$\u003c/span\u003e.\u003c/p\u003e\n \u003ch2\u003eSample 1\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n3 29 45 56 68\n1 19 43 50 72\n11 25 40 49 61\n9 23 31 58 63\n4 27 42 54 71\n\n14 23 39 59 63\n8 17 35 55 61\n15 26 42 53 71\n10 25 31 57 64\n6 20 44 52 68\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e1 2\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n \u003ch2\u003eSample 2\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e2\n2189 2127 1451 982 835\n150 1130 779 1326 1149\n2697 2960 315 534 2537\n2750 1771 875 1702 430\n300 2657 2827 983 947\n\n886 738 2569 1107 2758\n2795 173 1718 2294 1732\n1188 2273 2489 1251 2224\n431 1050 1764 1193 1566\n1194 1561 162 1673 2411\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eno ties\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}