{"trustable":false,"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":"MD","content":"给定 N \\* M 的字母矩阵,相邻两个格子之间有一条边,边权定义如下:\n* 如果两个格子的字母相同,则边权为 0;\n* 如果两个格子的字母不同,则边权为 1。\n\n问从左上角出发,经过任意路径(上下左右)到达右下角,最短的权重之和(即最短路)是多少。\n\n**多组输入输出**。\n\n---\n\n \u003ch3\u003eInput\u003c/h3\u003e\n \u003cp\u003eThe first line consists of an integer t, the number of test cases. For each test case, the first line consists of two integers R and C representing the order of the rectangular prison followed by R strings representing the map of the rectangular prison.\u003c/p\u003e\n \u003ch3\u003eOutput\u003c/h3\u003e\n \u003cp\u003eFor each test case find the minimum number of guards Kathiresan must kill in order to escape from the prison.\u003c/p\u003e\n \u003ch3\u003eConstraints\u003c/h3\u003e\n \u003cp\u003e1 \u0026lt;\u003d t \u0026lt;\u003d 10\u003c/p\u003e\n \u003cp\u003e2 \u0026lt;\u003d R \u0026lt;\u003d 1000\u003c/p\u003e\n \u003cp\u003e2 \u0026lt;\u003d C \u0026lt;\u003d 1000\u003c/p\u003e\n \u003cp\u003e\u0027a\u0027 \u0026lt;\u003d map[i][j] \u0026lt;\u003d \u0027z\u0027\u003c/p\u003e\n \u003ch3\u003eSample\u003c/h3\u003e\n \u003cpre\u003e\u003cstrong\u003eInput:\u003c/strong\u003e\n4\n2 2\naa\naa\n2 3\nabc\ndef\n6 6\nakaccc\naaacfc\namdfcc\naokhdd\nzyxwdp\nzyxwdd\n5 5\nabbbc\nabacc\naaacc\naefci\ncdgdd\n\n\u003cstrong\u003eOutput:\u003c/strong\u003e\n0\n3\n2\n2\n\u003c/pre\u003e\n\u003c/div\u003e"}}]}