knightnemo commited on
Commit
7689da3
·
verified ·
1 Parent(s): 0c0489f

Upload code_segments/segment_250.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. code_segments/segment_250.txt +17 -0
code_segments/segment_250.txt ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Narek is too lazy to create the third problem of this contest. His friend Artur suggests that he should use ChatGPT. ChatGPT creates $n$ problems, each consisting of $m$ letters, so Narek has $n$ strings. To make the problem harder, he combines the problems by selecting some of the $n$ strings possibly none and concatenating them without altering their order. His chance of solving the problem is defined as $score_n - score_c$, where $score_n$ is Narek's score and $score_c$ is ChatGPT's score.
2
+
3
+ Narek calculates $score_n$ by examining the selected string (he moves from left to right). He initially searches for the letter $\texttt{"n"}$, followed by $\texttt{"a"}$, $\texttt{"r"}$, $\texttt{"e"}$, and $\texttt{"k"}$. Upon finding all occurrences of these letters, he increments $score_n$ by $5$ and resumes searching for $\texttt{"n"}$ again (he doesn't go back, and he just continues from where he left off).
4
+
5
+ After Narek finishes, ChatGPT scans through the array and increments $score_c$ by $1$ for each letter $\texttt{"n"}$, $\texttt{"a"}$, $\texttt{"r"}$, $\texttt{"e"}$, or $\texttt{"k"}$ that Narek fails to utilize (note that if Narek fails to complete the last occurrence by finding all of the $5$ letters, then all of the letters he used are counted in ChatGPT's score $score_c$, and Narek doesn't get any points if he doesn't finish finding all the 5 letters).
6
+
7
+ Narek aims to maximize the value of $score_n - score_c$ by selecting the most optimal subset of the initial strings.
8
+
9
+ In the first line of the input, you're given a single integer $t$ ($1 \le t \le 10^5$), the number of test cases. Then the description of each test case follows.
10
+
11
+ In the first line of each test case, you're given two integers $n, m$ ($1 \le n, m \le 10^3$), the number of strings and the length of each string.
12
+
13
+ In the next $n$ lines, you're given $n$ strings, each having a length of $m$. The strings only contain lowercase letters of the English alphabet.
14
+
15
+ The sum of values of $n \cdot m$ over all test cases does not exceed $10^6$.
16
+
17
+ For each test