prithivMLmods/Coder-Stat
Coder-Stat Dataset Overview The Coder-Stat dataset is a collection of programming-related data, including problem IDs, programming languages, original statuses, and source code snippets. This dataset is designed to assist in the analysis of coding patterns, error types, and performance metrics. Dataset Details Modalities Tabular: The dataset is structured in a tabular format. Text: Contains text data, including source code snippets.… See the full description on the dataset page: https://huggingface.co/datasets/prithivMLmods/Coder-Stat.
3139
1 2<H1><font color="#000">Problem I:</font> Enjoyable Commutation</H1>3 4<p>5Isaac is tired of his daily trip to his ofice, using the same shortest route everyday. Although this saves his time, he must see the same scenery again and again. He cannot stand such a boring commutation any more.6</p>7<p>8One day, he decided to improve the situation. He would change his route everyday at least slightly. His new scheme is as follows. On the first day, he uses the shortest route. On the second day, he uses the second shortest route, namely the shortest except one used on the first day. In general, on the <i>k</i>-th day, the <i>k</i>-th shortest route is chosen. Visiting the same place twice on a route should be avoided, of course.9</p>10<p>11You are invited to help Isaac, by writing a program which finds his route on the <i>k</i>-th day. The problem is easily modeled using terms in the graph theory. Your program should find the <i>k</i>-th shortest path in the given directed graph.12</p>13 14<H2>Input</H2>15 16<p>17The input consists of multiple datasets, each in the following format.18</p>19 20<pre>21 <i>n m k a b</i>22 <i>x</i><sub>1</sub> <i>y</i><sub>1</sub> <i>d</i><sub>1</sub>23 <i>x</i><sub>2</sub> <i>y</i><sub>2</sub> <i>d</i><sub>2</sub>24 ...25 <i>x</i><sub><i>m</i></sub> <i>y</i><sub><i>m</i></sub> <i>d</i><sub><i>m</i></sub>26</pre>27 28<p>29Every input item in a dataset is a non-negative integer. Two or more input items in a line are separated by a space.30</p>31<p>32<i>n</i> is the number of nodes in the graph. You can assume the inequality 2 ≤ <i>n</i> ≤ 50. <i>m</i> is the number of (directed) edges. <i>a</i> is the start node, and <i>b</i> is the goal node. They are between 1 and <i>n</i>, inclusive. You are required to find the <i>k</i>-th shortest path from <i>a</i> to <i>b</i>. You can assume 1 ≤ <i>k</i> ≤ 200 and <i>a</i> ≠ <i>b</i>.33</p>34<p>35The <i>i</i>-th edge is from the node <i>x<sub>i</sub></i> to <i>y<sub>i</sub></i> with the length <i>d<sub>i</sub></i> (1 ≤ <i>i</i> ≤ <i>m</i>). Both <i>x<sub>i</sub></i> and <i>y<sub>i</sub></i> are between 1 and <i>n</i>, inclusive. <i>d<sub>i</sub></i> is between 1 and 10000, inclusive. You can directly go from <i>x<sub>i</sub></i> to <i>y<sub>i</sub></i>, but not from <i>y<sub>i</sub></i> to <i>x<sub>i</sub></i> unless an edge from <i>y<sub>i</sub></i> to <i>x<sub>i</sub></i> is explicitly given. The edge connecting the same pair of nodes is unique, if any, that is, if <i>i</i> ≠ <i>j</i>, it is never the case that <i>x<sub>i</sub></i> equals <i>x<sub>j</sub></i> and <i>y<sub>i</sub></i> equals <i>y<sub>j</sub></i>. Edges are not connecting a node to itself, that is, <i>x<sub>i</sub></i> never equals <i>y<sub>i</sub></i> . Thus the inequality 0 ≤ <i>m</i> ≤ <i>n</i>(<i>n</i> - 1) holds.36</p>37 38<p>39Note that the given graph may be quite unrealistic as a road network. Both the cases <i>m</i> = 0 and <i>m</i> = <i>n</i>(<i>n</i> - 1) are included in the judges' data.40</p>41<p>42The last dataset is followed by a line containing five zeros (separated by a space).43 44</p>45 46<H2>Output</H2>47 48<p>49For each dataset in the input, one line should be output as specified below. An output line should not contain extra characters such as spaces.50</p>51 52<p>53If the number of distinct paths from <i>a</i> to <i>b</i> is less than <i>k</i>, the string <span>None</span> should be printed. Note that the first letter of <span>None</span> is in uppercase, while the other letters are in lowercase.54</p>55 56<p>57If the number of distinct paths from <i>a</i> to <i>b</i> is <i>k</i> or more, the node numbers visited in the <i>k</i>-th shortest path should be printed in the visited order, separated by a hyphen (minus sign). Note that <i>a</i> must be the first, and <i>b</i> must be the last in the printed line.58</p>59 60<p>61In this problem the term <i>shorter</i> (thus <i>shortest</i> also) has a special meaning. A path <i>P</i> is defined to be shorter than <i>Q</i>, if and only if one of the following conditions holds.62</p>63 64<ol>65 <li> The length of <i>P</i> is less than the length of <i>Q</i>. The length of a path is defined to be the sum of lengths of edges on the path.</li>66 <li> The length of <i>P</i> is equal to the length of <i>Q</i>, and <i>P</i>'s sequence of node numbers comes earlier than <i>Q</i>'s in the dictionary order. Let's specify the latter condition more precisely. Denote <i>P</i>'s sequence of node numbers by <i>p</i><sub>1</sub>, <i>p</i><sub>2</sub>,..., <i>p<sub>s</sub></i>, and <i>Q</i>'s by <i>q</i><sub>1</sub>, <i>q</i><sub>2</sub>,..., <i>q<sub>t</sub></i>. <i>p</i><sub>1</sub> = <i>q</i><sub>1</sub> = <i>a</i> and <i>p<sub>s</sub></i> = <i>q<sub>t</sub></i> = <i>b</i> should be observed. The sequence <i>P</i> comes earlier than <i>Q</i> in the dictionary order, if for some <i>r</i> (1 ≤ <i>r</i> ≤ <i>s</i> and <i>r</i> ≤ <i>t</i>), <i>p</i><sub>1</sub> = <i>q</i><sub>1</sub>,..., <i>p</i><sub><i>r</i>-1</sub> = <i>q</i><sub><i>r</i>-1</sub>, and <i>p<sub>r</sub></i> < <i>q<sub>r</sub></i> (<i>p<sub>r</sub></i> is numerically smaller than <i>q<sub>r</sub></i>).67</ol>68 69<p>70A path visiting the same node twice or more is not allowed.71</p>72 73<H2>Sample Input</H2>74<pre>755 20 10 1 5761 2 1771 3 2781 4 1791 5 3802 1 1812 3 1822 4 2832 5 2843 1 1853 2 2863 4 1873 5 1884 1 1894 2 1904 3 1914 5 2925 1 1935 2 1945 3 1955 4 1964 6 1 1 4972 4 2981 3 2991 2 11001 4 31012 3 11023 4 11033 3 5 1 31041 2 11052 3 11061 3 11070 0 0 0 0108</pre>109 110<H2>Output for the Sample Input</H2>111<pre>1121-2-4-3-51131-2-3-4114None115</pre>116 117<p>118In the case of the first dataset, there are 16 paths from the node 1 to 5. They are ordered as follows (The number in parentheses is the length of the path).119</p>120 121<pre>1221 (3) 1-2-3-5 9 (5) 1-2-3-4-51232 (3) 1-2-5 10 (5) 1-2-4-3-51243 (3) 1-3-5 11 (5) 1-2-4-51254 (3) 1-4-3-5 12 (5) 1-3-4-51265 (3) 1-4-5 13 (6) 1-3-2-51276 (3) 1-5 14 (6) 1-3-4-2-51287 (4) 1-4-2-3-5 15 (6) 1-4-3-2-51298 (4) 1-4-2-5 16 (8) 1-3-2-4-5130</pre>131 132 133 134 135 136 