Classic
Clean & simple
Crystal
Glassmorphism + Neon
Cyberpunk
Neon glitch art
🚫
违规Action检测
禁止Use右键菜单
⚠️ 此Action已被系统记录
1

Stones on the Table

📝 Solutions 🔵 仅限 C++
Problems Description
<p><span style="font-size: large;"><span style="font-family: Arial;">&nbsp;&nbsp;&nbsp; &nbsp; There are n stones on the table in a row, each of them can be red, green or blue. Count the minimum number of stones to take from the table so that any two neighboring stones had different colors. Stones in a row are considered neighboring if there are no other stones between them.<br /> </span></span></p>
Input格式
<p><span style="font-size: large;"><span style="font-family: Arial;">&nbsp;&nbsp;&nbsp;&nbsp; The first line contains integer n (1&lt;=n&lt;=50) &iexcl;&ordf; the number of stones on the table. <br /> &nbsp;<br /> &nbsp;&nbsp;&nbsp;&nbsp; The next line contains string s, which represents the colors of the stones. We'll consider the stones in the row numbered from 1 to n from left to right. Then the i-th character s equals &quot;R&quot;, if the i-th stone is red, &quot;G&quot;, if it's green and &quot;B&quot;, if it's blue.</span></span></p>
Output格式
<p><span style="font-size: large;"><span style="font-family: Arial;">&nbsp;&nbsp;&nbsp;&nbsp; Print a single integer &iexcl;&ordf; the answer to the problem.<br /> </span></span></p>
Sample
Sample Input 1
3 RRG 5 RRRRR 4 BRBG
Sample Output 1
1 4 0
Submit Code
请先Login后Submit

🤖 AI 解题助手

OpenRouter
就绪
👋 你好!我是 AI 解题助手。
我已阅读了这problems题,可以帮你points析思路、提供Code示例。
🔓 完全Free · 无需消耗 Token