mirror of
https://github.com/xlucn/PAT.git
synced 2026-11-05 06:37:35 +08:00
23 lines
3.7 KiB
HTML
23 lines
3.7 KiB
HTML
Programming Pattern
|
|
<div class="ques-view"><p>Programmers often have a preference among program constructs. For example, some may prefer <code>if(0==a)</code>, while others may prefer <code>if(!a)</code>. Analyzing such patterns can help to narrow down a programmer's identity, which is useful for detecting plagiarism.</p>
|
|
<p>Now given some text sampled from someone's program, can you find the person's most commonly used pattern of a specific length?</p>
|
|
<h3 id="input-specification-">Input Specification:</h3>
|
|
<p>Each input file contains one test case. For each case, there is one line consisting of the pattern length <span class="katex"><span class="katex-mathml"><math><mrow><mi>N</mi></mrow>N</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.10903em;">N</span></span></span></span> (<span class="katex"><span class="katex-mathml"><math><mrow><mn>1</mn><mo>≤</mo><mi>N</mi><mo>≤</mo><mn>1</mn><mn>0</mn><mn>4</mn><mn>8</mn><mn>5</mn><mn>7</mn><mn>6</mn></mrow>1\le N\le 1048576</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.8193em;vertical-align:-0.13597em;"></span><span class="base textstyle uncramped"><span class="mord mathrm">1</span><span class="mrel">≤</span><span class="mord mathit" style="margin-right:0.10903em;">N</span><span class="mrel">≤</span><span class="mord mathrm">1</span><span class="mord mathrm">0</span><span class="mord mathrm">4</span><span class="mord mathrm">8</span><span class="mord mathrm">5</span><span class="mord mathrm">7</span><span class="mord mathrm">6</span></span></span></span>), followed by one line no less than <span class="katex"><span class="katex-mathml"><math><mrow><mi>N</mi></mrow>N</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.10903em;">N</span></span></span></span> and no more than 1048576 characters in length, terminated by a carriage return <code>\n</code>. The entire input is case sensitive.</p>
|
|
<h3 id="output-specification-">Output Specification:</h3>
|
|
<p>For each test case, print in one line the length-<span class="katex"><span class="katex-mathml"><math><mrow><mi>N</mi></mrow>N</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.68333em;"></span><span class="strut bottom" style="height:0.68333em;vertical-align:0em;"></span><span class="base textstyle uncramped"><span class="mord mathit" style="margin-right:0.10903em;">N</span></span></span></span> substring that occurs most frequently in the input, followed by a space and the number of times it has occurred in the input. If there are multiple such substrings, print the lexicographically smallest one.</p>
|
|
<p>Whitespace characters in the input should be printed as they are. Also note that there may be multiple occurrences of the same substring overlapping each other.</p>
|
|
<h3 id="sample-input-1-">Sample Input 1:</h3>
|
|
<pre><code class="lang-in">4
|
|
//A can can can a can.
|
|
</code></pre>
|
|
<h3 id="sample-output-1-">Sample Output 1:</h3>
|
|
<pre><code class="lang-out"> can 4
|
|
</code></pre>
|
|
<h3 id="sample-input-2-">Sample Input 2:</h3>
|
|
<pre><code class="lang-in">3
|
|
int a=~~~~~~~~~~~~~~~~~~~~~0;
|
|
</code></pre>
|
|
<h3 id="sample-output-2-">Sample Output 2:</h3>
|
|
<pre><code class="lang-out">~~~ 19
|
|
</code></pre>
|
|
</div> |