{"trustable":false,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n section pre {\n display: block;\n padding: 9.5px;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n word-break: break-all;\n word-wrap: break-word;\n color: #333;\n background: rgba(255, 255, 255, 0.5);\n border: 1px solid #ccc;\n border-radius: 6px;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\(\u0027, right: \u0027\\\\)\u0027, display: false},\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"Problem Statement","value":{"format":"HTML","content":"\u003csection\u003e \n \u003cp\u003eSkenu constructed a building that has \u003cvar\u003e\\(N\\)\u003c/var\u003e floors. The building has an elevator that stops at every floor.\u003c/p\u003e \n \u003cp\u003eThere are buttons to control the elevator, but Skenu thoughtlessly installed only one button on each floor - up or down. This means that, from each floor, one can only go in one direction. If \u003cvar\u003e\\(S_i\\)\u003c/var\u003e is \u003ccode\u003eU\u003c/code\u003e, only \"up\" button is installed on the \u003cvar\u003e\\(i\\)\u003c/var\u003e-th floor and one can only go up; if \u003cvar\u003e\\(S_i\\)\u003c/var\u003e is \u003ccode\u003eD\u003c/code\u003e, only \"down\" button is installed on the \u003cvar\u003e\\(i\\)\u003c/var\u003e-th floor and one can only go down.\u003c/p\u003e \n \u003cp\u003eThe residents have no choice but to go to their destination floors via other floors if necessary. Find the sum of the following numbers over all ordered pairs of two floors \u003cvar\u003e\\((i,j)\\)\u003c/var\u003e: the minimum number of times one needs to take the elevator to get to the \u003cvar\u003e\\(j\\)\u003c/var\u003e-th floor from the \u003cvar\u003e\\(i\\)\u003c/var\u003e-th floor.\u003c/p\u003e \n\u003c/section\u003e\n题目大意:给你一个字符串S,对于每个Si代表的都是楼层i的按钮\u003cp\u003e如果是\u0027D\u0027代表楼层i的用户只能到达i-1,i-2....的楼层\u003cp\u003e\n如果是\u0027U\u0027代表楼层i的用户只能到达i+1,i+2...的楼层\u003cp\u003e\n输出对于所有的a-b(楼层a的用户到达楼层b,a!\u003db)的最少乘坐电梯次数的和\n\u003cp\u003ea-b-c-d,从a到b,再从b到c,从c到d,记做a-d的乘坐次数为3次(不一定为最少次数)"}},{"title":"Constraints","value":{"format":"HTML","content":"\u003csection\u003e \n \u003cul\u003e \n \u003cli\u003e\u003cvar\u003e\\(2 ≤ |S| ≤ 10^5\\)\u003c/var\u003e\u003c/li\u003e \n \u003cli\u003e\u003cvar\u003e\\(S_i\\)\u003c/var\u003e is either \u003ccode\u003eU\u003c/code\u003e or \u003ccode\u003eD\u003c/code\u003e.\u003c/li\u003e \n \u003cli\u003e\u003cvar\u003e\\(S_1\\)\u003c/var\u003e is \u003ccode\u003eU\u003c/code\u003e.\u003c/li\u003e \n \u003cli\u003e\u003cvar\u003e\\(S_{|S|}\\)\u003c/var\u003e is \u003ccode\u003eD\u003c/code\u003e.\u003c/li\u003e \n \u003c/ul\u003e \n\u003c/section\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003csection\u003e \n \u003cp\u003eThe input is given from Standard Input in the following format:\u003c/p\u003e \n \u003cpre\u003e\u003cvar\u003e\\(S_1S_2...S_{|S|}\\)\u003c/var\u003e\n\u003c/pre\u003e \n\u003c/section\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003csection\u003e \n \u003cp\u003ePrint the sum of the following numbers over all ordered pairs of two floors \u003cvar\u003e\\((i,j)\\)\u003c/var\u003e: the minimum number of times one needs to take the elevator to get to the \u003cvar\u003e\\(j\\)\u003c/var\u003e-th floor from the \u003cvar\u003e\\(i\\)\u003c/var\u003e-th floor.\u003c/p\u003e \n\u003c/section\u003e"}},{"title":"Sample 1","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\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\u003eUUD\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e7\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003csection\u003e \n\u003c/section\u003e\u003csection\u003e \n \u003cp\u003eFrom the \u003cvar\u003e\\(1\\)\u003c/var\u003e-st floor, one can get to the \u003cvar\u003e\\(2\\)\u003c/var\u003e-nd floor by taking the elevator once.\u003c/p\u003e \n \u003cp\u003eFrom the \u003cvar\u003e\\(1\\)\u003c/var\u003e-st floor, one can get to the \u003cvar\u003e\\(3\\)\u003c/var\u003e-rd floor by taking the elevator once.\u003c/p\u003e \n \u003cp\u003eFrom the \u003cvar\u003e\\(2\\)\u003c/var\u003e-nd floor, one can get to the \u003cvar\u003e\\(1\\)\u003c/var\u003e-st floor by taking the elevator twice.\u003c/p\u003e \n \u003cp\u003eFrom the \u003cvar\u003e\\(2\\)\u003c/var\u003e-nd floor, one can get to the \u003cvar\u003e\\(3\\)\u003c/var\u003e-rd floor by taking the elevator once.\u003c/p\u003e \n \u003cp\u003eFrom the \u003cvar\u003e\\(3\\)\u003c/var\u003e-rd floor, one can get to the \u003cvar\u003e\\(1\\)\u003c/var\u003e-st floor by taking the elevator once.\u003c/p\u003e \n \u003cp\u003eFrom the \u003cvar\u003e\\(3\\)\u003c/var\u003e-rd floor, one can get to the \u003cvar\u003e\\(2\\)\u003c/var\u003e-nd floor by taking the elevator once.\u003c/p\u003e \n \u003cp\u003eThe sum of these numbers of times, \u003cvar\u003e\\(7\\)\u003c/var\u003e, should be printed.\u003c/p\u003e \n\u003c/section\u003e"}},{"title":"Sample 2","value":{"format":"HTML","content":"\u003ctable class\u003d\u0027vjudge_sample\u0027\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\u003eUUDUUDUD\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e77\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003csection\u003e \n\u003c/section\u003e\u003csection\u003e \n\u003c/section\u003e"}}]}