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<script type="text/x-mathjax-config">3 MathJax.Hub.Config({ tex2jax: { inlineMath: [["$","$"], ["\\(","\\)"]], processEscapes: true }});4</script>5<script type='text/javascript' src='http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML'></script>6</script>7 8 9<h2>Problem A:10Bit String Reordering11</h2>12 13<p>14 You have to reorder a given bit string as specified. The only operation allowed is swapping adjacent bit pairs. Please write a program that calculates the minimum number of swaps required.15</p>16 17<p>18 The initial bit string is simply represented by a sequence of bits, while the target is specified by a <i>run-length code</i>. The run-length code of a bit string is a sequence of the lengths of maximal consecutive sequences of zeros or ones in the bit string. For example, the run-length code of "011100" is "1 3 2". Note that there are two different bit strings with the same run-length code, one starting with zero and the other starting with one. The target is either of these two.19</p>20 21<p>22 In Sample Input 1, bit string "100101" should be reordered so that its run-length code is "1 3 2", which means either "100011" or "011100". At least four swaps are required to obtain "011100". On the other hand, only one swap is required to make "100011". Thus, in this example, 1 is the answer.23</p>24 25<h3>Input</h3>26 27 28<p>29The input consists of a single test case. The test case is formatted as follows. <br>30<br>31$N$ $M$<br>32$b_1$ $b_2$ . . . $b_N$<br>33$p_1$ $p_2$ . . . $p_M$<br>34<br>35 36 37The first line contains two integers $N$ ($1 \leq N \leq 15$) and $M$ ($1 \leq M \leq N$). The second line38specifies the initial bit string by $N$ integers. Each integer $b_i$ is either 0 or 1. The third line contains the run-length code, consisting of $M$ integers. Integers $p_1$ through $p_M$ represent the lengths of consecutive sequences of zeros or ones in the bit string, from left to right. Here, $1 \leq p_j$ for $1 \leq j \leq M$ and $\sum^{M}_{j=1} p_j = N$ hold. It is guaranteed that the initial bit string can be reordered into a bit string with its run-length code $p_1, . . . , p_M$.39</p>40 41 42<h3>Output</h3>43 44<p>45Output the minimum number of swaps required46</p>47 48 49 50<h3>Sample Input 1</h3>51 52<pre>6 3531 0 0 1 0 1541 3 2</pre>55 56<h3>Sample Output 1</h3>57 58<pre>1</pre>59 60<h3>Sample Input 2</h3>61 62<pre>7 2631 1 1 0 0 0 0644 3</pre>65 66<h3>Sample Output 2</h3>67 68<pre>12</pre>69 70<h3>Sample Input 3</h3>71 72<pre>15 14731 0 1 0 1 0 1 0 1 0 1 0 1 0 1741 1 1 1 1 1 1 1 1 1 1 1 1 2</pre>75 76<h3>Sample Output 3</h3>77 78<pre>7</pre>79 80<h3>Sample Input 4</h3>81 82<pre>1 1830841</pre>85 86<h3>Sample Output 4</h3>87 88<pre>0</pre>89 