{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n #problem-body \u003e 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","sections":[{"title":"","value":{"format":"HTML","content":"\u003cdiv id\u003d\"problem-body\"\u003e\n\t\u003cp\u003eGiven a string of length at most 100,000 consist of alphabets and numbers. Output the suffix array of the string.\u003c/p\u003e\r\n\u003cp\u003eA \u003ca href\u003d\"//en.wikipedia.org/wiki/Suffix_array\"\u003esuffix array\u003c/a\u003e is an array of integers giving the starting positions (0-based) of suffixes of a string in lexicographical order. Consider a string \"abracadabra0AbRa4Cad14abra\". The size of the suffix array is equal to the length of the string. Below is the list of 26 suffixes of the string along with its starting position sorted in lexicographical order:\u003c/p\u003e\r\n\u003cpre\u003e\u003cstrong\u003e\u003cspan style\u003d\"font-family: \u0027courier new\u0027, courier; font-size:12px\"\u003ePOS SUFFIX\u003c/span\u003e\u003c/strong\u003e\u003cspan style\u003d\"font-family: \u0027courier new\u0027, courier; font-size:12px\"\u003e\r\n 11 0AbRa4Cad14abra\r\n 20 14abra\r\n 16 4Cad14abra\r\n 21 4abra\r\n 12 AbRa4Cad14abra\r\n 17 Cad14abra\r\n 14 Ra4Cad14abra\r\n 25 a\r\n 10 a0AbRa4Cad14abra\r\n 15 a4Cad14abra\r\n 22 abra\r\n 7 abra0AbRa4Cad14abra\r\n 0 abracadabra0AbRa4Cad14abra\r\n 3 acadabra0AbRa4Cad14abra\r\n 18 ad14abra\r\n 5 adabra0AbRa4Cad14abra\r\n 13 bRa4Cad14abra\r\n 23 bra\r\n 8 bra0AbRa4Cad14abra\r\n 1 bracadabra0AbRa4Cad14abra\r\n 4 cadabra0AbRa4Cad14abra\r\n 19 d14abra\r\n 6 dabra0AbRa4Cad14abra\r\n 24 ra\r\n 9 ra0AbRa4Cad14abra\r\n 2 racadabra0AbRa4Cad14abra\u003c/span\u003e\r\n\u003c/pre\u003e\r\n\u003cp\u003e\u003cstrong\u003eNote\u003c/strong\u003e: this is a partial score problem.\u003cbr\u003e O(n\u003csup\u003e2\u003c/sup\u003e log(n)) is expected to score about 20-30. (Naive sorting all suffixes)\u003cbr\u003e O(n log\u003csup\u003e2\u003c/sup\u003e(n)) is expected to score about 40. (OK for most programming contest problems)\u003cbr\u003e O(n log n) is expected to score about 60-70. (Use counting sort for small alphabet size)\u003cbr\u003eO(n) without tweaks is expected to score about 80-90.\u003cbr\u003eO(n) with tweaks is expected to score 100. (This is meant for fun only :)\u003c/p\u003e\r\n\u003ch3\u003eInput\u003c/h3\u003e\r\n\u003cp\u003eA single line containing the string.\u003c/p\u003e\r\n\u003ch3\u003eOutput\u003c/h3\u003e\r\n\u003cp\u003eThe suffix array of the string.\u003c/p\u003e\r\n\u003ch3\u003eExample\u003c/h3\u003e\r\n\u003cdiv\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\u003eabracadabra0AbRa4Cad14abra\r\n\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e11\r\n20\r\n16\r\n21\r\n12\r\n17\r\n14\r\n25\r\n10\r\n15\r\n22\r\n7\r\n0\r\n3\r\n18\r\n5\r\n13\r\n23\r\n8\r\n1\r\n4\r\n19\r\n6\r\n24\r\n9\r\n2\r\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/div\u003e\n\u003c/div\u003e"}}]}