{"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 \u003cp\u003eAndrew the Ant is fascinated by the behavior of his friends.\n Thousands of them are marching their paths on and on. They can\n build highly organized ant-hills. Sometimes, however, they act\n a little bit stupidly.\u003c/p\u003e\n\n \u003cp\u003eRecently, Andrew watched his fellow ants marching on top of\n a long piece of wood. He noticed their behavioral pattern is\n very simple: Each ant walks slowly forward with a constant\n speed of \u003cspan class\u003d\"tex2jax_process\"\u003e$1\\, \\mathrm{cm}$\u003c/span\u003e\n per second. Whenever it meets another ant, both of them only\n touch with their antennae and immediately turn around and walk\n the opposite direction. If an ant comes to the end of the wood,\n it falls down and does not affect other ants anymore.\u003c/p\u003e\n\n \u003cdiv id\u003d\"fig:sample3\" class\u003d\"figure\"\u003e\n \u003ccenter\u003e\n \u003cimg src\u003d\"CDN_BASE_URL/c9899cf3bd3927e08812d77a23a31cb6?v\u003d1715307044\" alt\u003d\"\\includegraphics[width\u003d0.8\\textwidth ]{sample3.pdf}\" style\u003d\"width:80.00%\"\u003e\n\n \u003cdiv class\u003d\"caption\"\u003e\n \u003cb\u003eFigure 1\u003c/b\u003e: Picture of the third sample input at\n time \u003cspan class\u003d\"tex2jax_process\"\u003e$0\\,\n \\mathrm{s}$\u003c/span\u003e. In one second, the ants \u003cspan class\u003d\"tex2jax_process\"\u003e$E$\u003c/span\u003e and \u003cspan class\u003d\"tex2jax_process\"\u003e$A$\u003c/span\u003e meet at position\n \u003cspan class\u003d\"tex2jax_process\"\u003e$2$\u003c/span\u003e and change their\n directions. The ant \u003cspan class\u003d\"tex2jax_process\"\u003e$A$\u003c/span\u003e then meets \u003cspan class\u003d\"tex2jax_process\"\u003e$B$\u003c/span\u003e in the next \u003cspan class\u003d\"tex2jax_process\"\u003e$1.5$\u003c/span\u003e seconds. At the same time\n (\u003cspan class\u003d\"tex2jax_process\"\u003e$2.5$\u003c/span\u003e seconds after\n the start), the ants \u003cspan class\u003d\"tex2jax_process\"\u003e$C$\u003c/span\u003e and \u003cspan class\u003d\"tex2jax_process\"\u003e$D$\u003c/span\u003e will meet too. All four of\n them change their directions. In the next \u003cspan class\u003d\"tex2jax_process\"\u003e$0.5$\u003c/span\u003e seconds (time \u003cspan class\u003d\"tex2jax_process\"\u003e$3\\, \\mathrm{s}$\u003c/span\u003e), the first ant\n (\u003cspan class\u003d\"tex2jax_process\"\u003e$E$\u003c/span\u003e) falls down off\n the left end, etc.\n \u003c/div\u003e\n \u003c/center\u003e\n \u003c/div\u003e\n\n \u003cp\u003eYour task is to simulate the movement of ants. For\n simplicity, suppose that the ants have zero size (although the\n picture could suggest something else).\u003c/p\u003e\n\n \u003ch2\u003eInput\u003c/h2\u003e\n\n \u003cp\u003eThe input consists of several scenarios, at most\n \u003cspan class\u003d\"tex2jax_process\"\u003e$5$\u003c/span\u003e. Each scenario starts\n with a line containing two integer numbers \u003cspan class\u003d\"tex2jax_process\"\u003e$L$\u003c/span\u003e and \u003cspan class\u003d\"tex2jax_process\"\u003e$A$\u003c/span\u003e, separated by a space.\n \u003cspan class\u003d\"tex2jax_process\"\u003e$L$\u003c/span\u003e is the length of the\n wood in centimetres (\u003cspan class\u003d\"tex2jax_process\"\u003e$1 \\leq L\n \\leq 99\\, 999$\u003c/span\u003e), and \u003cspan class\u003d\"tex2jax_process\"\u003e$A$\u003c/span\u003e is the number of ants at the\n beginning of the simulation (\u003cspan class\u003d\"tex2jax_process\"\u003e$1\n \\leq A \\leq L + 1$\u003c/span\u003e). Then there are \u003cspan class\u003d\"tex2jax_process\"\u003e$A$\u003c/span\u003e lines, each containing a\n non-negative integer \u003cspan class\u003d\"tex2jax_process\"\u003e$X_\n i$\u003c/span\u003e, one space, and an uppercase letter. The number\n (\u003cspan class\u003d\"tex2jax_process\"\u003e$0 \\leq X_ i \\leq L$\u003c/span\u003e)\n specifies the position of the \u003cspan class\u003d\"tex2jax_process\"\u003e$i$\u003c/span\u003e-th ant and the letter its initial\n direction: either “\u003ctt class\u003d\"ttfamily\"\u003eL\u003c/tt\u003e” for left\n (towards zero) or “\u003ctt class\u003d\"ttfamily\"\u003eR\u003c/tt\u003e” for right. No\n two ants will start at the same position.\u003c/p\u003e\n\n \u003ch2\u003eOutput\u003c/h2\u003e\n\n \u003cp\u003eFor each scenario, you should print a single line containing\n the text “\u003ctt class\u003d\"ttfamily\"\u003eThe last ant will fall down in\n \u003cspan class\u003d\"tex2jax_process\"\u003e$T$\u003c/span\u003e seconds - started at\n \u003cspan class\u003d\"tex2jax_process\"\u003e$P$\u003c/span\u003e.\u003c/tt\u003e”, where\n \u003cspan class\u003d\"tex2jax_process\"\u003e$T$\u003c/span\u003e is the exact time when\n the last ant (or two) reaches the end of the wood, and\n \u003cspan class\u003d\"tex2jax_process\"\u003e$P$\u003c/span\u003e is the position where\n that particular ant has originally started in time \u003cspan class\u003d\"tex2jax_process\"\u003e$0$\u003c/span\u003e. If two last ants fall down at the\n same time, print “\u003ctt class\u003d\"ttfamily\"\u003estarted at \u003cspan class\u003d\"tex2jax_process\"\u003e$P$\u003c/span\u003e and \u003cspan class\u003d\"tex2jax_process\"\u003e$Q$\u003c/span\u003e\u003c/tt\u003e”, indicating both of their\n positions, \u003cspan class\u003d\"tex2jax_process\"\u003e$P \u0026lt; Q$\u003c/span\u003e.\u003c/p\u003e\n\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\u003e90000 1\n0 R\n10 1\n0 L\n14 5\n3 L\n6 L\n13 L\n8 R\n1 R\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003eThe last ant will fall down in 90000 seconds - started at 0.\nThe last ant will fall down in 0 seconds - started at 0.\nThe last ant will fall down in 13 seconds - started at 6 and 8.\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}