锘??xml version="1.0" encoding="utf-8" standalone="yes"?>欧美性事在线,亚洲一二三区精品,亚洲人成毛片在线播放http://m.shnenglu.com/Ylemzy/category/13550.html瓚寵抗鐨勮凍榪?/description>zh-cnFri, 09 Sep 2011 08:33:07 GMTFri, 09 Sep 2011 08:33:07 GMT60hdu 3415 Max Sum of Max-K-sub-sequence 鈥斺斿崟璋冮槦鍒?/title><link>http://m.shnenglu.com/Ylemzy/articles/134149.html</link><dc:creator>鐏⒊榛?/dc:creator><author>鐏⒊榛?/author><pubDate>Sat, 20 Nov 2010 05:17:00 GMT</pubDate><guid>http://m.shnenglu.com/Ylemzy/articles/134149.html</guid><wfw:comment>http://m.shnenglu.com/Ylemzy/comments/134149.html</wfw:comment><comments>http://m.shnenglu.com/Ylemzy/articles/134149.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://m.shnenglu.com/Ylemzy/comments/commentRss/134149.html</wfw:commentRss><trackback:ping>http://m.shnenglu.com/Ylemzy/services/trackbacks/134149.html</trackback:ping><description><![CDATA[<p>鍗曡皟闃熷垪:瀛樻斁涓涓崟璋冨簭鍒椼傜敤浜庡浜庝竴涓粰瀹氬ぇ灝忎負k鐨勫尯闂達紝姹傚嚭鍖洪棿鍐呯殑鏈鍊奸棶棰樸?/p> <p>闃熷垪鍙互鍙岀鍑洪槦錛岄槦鍒楀彲浠ョ湅鎴愪竴鍗婃槸瀛樻斁榪囨湡鐨勫鹼紝涓鍗婃槸瀛樻斁瀵規湭鏉ユ湁鐢ㄧ殑鍊箋?/p> <p>浠[i]緇撳熬鐨刱紿楀彛鍐呯殑鏈澶у糵[i] = Max{a[i-k+1] ... a[i]};f[i+1] = Max{a[i+1-k+1]... a[i+1]};</p> <p>鎵浠ュ湪姹俧[i+1]鏃訛紝鍙互鍒╃敤姹俧[i]鏃剁瓫閫夊嚭瀵筬[i+1]鏈夋晥鐨勫箋?/p> <p>鍦ㄦ眰f[i]鏃訛紝鍦ㄥ尯闂碵i-k+1 + 1,i]鍐呯殑鍊兼墠瀵筬[i+1]鏈夋晥錛堝彲浠ュ湪闃熷垪浠庡ご寮濮嬪垽鏂笅鏍囨潵鍒犻櫎涓浜涜繃鏈熷鹼級銆傝屽湪榪欎釜鏈夋晥鍖洪棿鍐咃紝姣攁[i]灝忕殑鏁板f[i+1]涓嶆槸蹇呰鐨勶紝鎵浠ュ彧闇瑕佸瓨鏀綼[i]錛屾瘮a[i]澶х殑鏁板f[i+1]鍙兘鏄繀瑕佺殑錛屽氨涓嶈兘鍒犻櫎錛堥氳繃浠庨槦灝懼紑濮嬪垹闄ゆ瘮a[i]灝忕殑鍊?銆傚垹闄ゅソ鍚庣殑闃熷垪瀛樻斁鐨勬槸涓涓粠澶у埌灝忕殑鏈夋晥鍊煎簭鍒楋紝閭[i]灝辨槸闃熷ご鍏冪礌浜嗐?/p> <h1 style="color: #1a5cc8;">Max Sum of Max-K-sub-sequence</h1> <font><strong><span style="font-family: Arial; font-size: 12px; font-weight: bold; color: green;"></span></strong></font><br> <div id="hvzpftn" class="panel_title" align="left">Problem Description</div> <div id="hvzpftn" class="panel_content">Given a circle sequence A[1],A[2],A[3]......A[n]. Circle sequence means the left neighbour of A[1] is A[n] , and the right neighbour of A[n] is A[1].<br>Now your job is to calculate the max sum of a Max-K-sub-sequence. Max-K-sub-sequence means a continuous non-empty sub-sequence which length not exceed K.</div> <div id="hvzpftn" class="panel_bottom"> </div> <br> <div id="hvzpftn" class="panel_title" align="left">Input</div> <div id="hvzpftn" class="panel_content">The first line of the input contains an integer T(1<=T<=100) which means the number of test cases. <br>Then T lines follow, each line starts with two integers N , K(1<=N<=100000 , 1<=K<=N), then N integers followed(all the integers are between -1000 and 1000). </div> <div id="hvzpftn" class="panel_bottom"> </div> <br> <div id="hvzpftn" class="panel_title" align="left">Output</div> <div id="hvzpftn" class="panel_content">For each test case, you should output a line contains three integers, the Max Sum in the sequence, the start position of the sub-sequence, the end position of the sub-sequence. If there are more than one result, output the minimum start position, if still more than one , output the minimum length of them.</div> <div id="hvzpftn" class="panel_bottom"> </div> <br> <div id="hvzpftn" class="panel_title" align="left">Sample Input</div> <div id="hvzpftn" class="panel_content"> <pre> <div style="font-family: Courier New,Courier,monospace;">4<br>6 3<br>6 -1 2 -6 5 -5<br>6 4<br>6 -1 2 -6 5 -5<br>6 3<br>-1 2 -6 5 -5 6<br>6 6<br>-1 -1 -1 -1 -1 -1</div> </pre> </div> <div id="hvzpftn" class="panel_bottom"> </div> <br> <div id="hvzpftn" class="panel_title" align="left">Sample Output</div> <div id="hvzpftn" class="panel_content"> <pre> <div style="font-family: Courier New,Courier,monospace;">7 1 3<br>7 1 3<br>7 6 2<br>-1 1 1<br>棰樻剰錛氱粰瀹氭瀯鎴愬渾鐜殑搴忓垪鍜屼竴涓猭紿楀彛錛屾眰(鏈澶х殑涓嶈秴榪噆闀垮害鐨勬渶澶у瓧孌靛拰) 涓?(瀛愭鍜岄暱搴﹀彇闀垮害鏈灝忕殑)銆?br> <div style="background-color: #eeeeee; font-size: 13px; border: 1px solid #cccccc; padding: 4px 5px 4px 4px; width: 98%;"><!--<br><br>Code highlighting produced by Actipro CodeHighlighter (freeware)<br>http://www.CodeHighlighter.com/<br><br>--><span style="color: #000000;">#include </span><span style="color: #000000;"><</span><span style="color: #000000;">iostream</span><span style="color: #000000;">></span><span style="color: #000000;"><br></span><span style="color: #0000ff;">#define</span><span style="color: #000000;"> maxn 200010</span><span style="color: #000000;"><br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> num[maxn], que[maxn], sum[maxn], ans[maxn];<br></span><span style="color: #0000ff;">int</span><span style="color: #000000;"> main()<br>{ <br>    </span><span style="color: #0000ff;">int</span><span style="color: #000000;"> t, n, k, m, i, j, a, b, c, p, max, ksum, len;<br>    scanf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%d</span><span style="color: #000000;">"</span><span style="color: #000000;">, </span><span style="color: #000000;">&</span><span style="color: #000000;">t);<br>    </span><span style="color: #0000ff;">while</span><span style="color: #000000;"> (t</span><span style="color: #000000;">--</span><span style="color: #000000;">)<br>    {<br>        scanf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%d%d</span><span style="color: #000000;">"</span><span style="color: #000000;">, </span><span style="color: #000000;">&</span><span style="color: #000000;">n, </span><span style="color: #000000;">&</span><span style="color: #000000;">k);<br>        m </span><span style="color: #000000;">=</span><span style="color: #000000;"> n;<br>        </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">; i </span><span style="color: #000000;"><=</span><span style="color: #000000;"> n; i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>        {<br>            scanf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%d</span><span style="color: #000000;">"</span><span style="color: #000000;">, </span><span style="color: #000000;">&</span><span style="color: #000000;">num[i]);<br>        }<br>        </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (j </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">; j </span><span style="color: #000000;"><</span><span style="color: #000000;"> k; j</span><span style="color: #000000;">++</span><span style="color: #000000;">, i</span><span style="color: #000000;">++</span><span style="color: #000000;">)</span><span style="color: #008000;">//</span><span style="color: #008000;">鏋勬垚<img src="http://m.shnenglu.com/Images/dot.gif"> n - 1, n, 1, 2, <img src="http://m.shnenglu.com/Images/dot.gif">, k - 1</span><span style="color: #008000;"><br></span><span style="color: #000000;">        {<br>            num[i] </span><span style="color: #000000;">=</span><span style="color: #000000;"> num[j];<br>        }<br>        n </span><span style="color: #000000;">=</span><span style="color: #000000;"> i;<br>        </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (sum[</span><span style="color: #000000;">0</span><span style="color: #000000;">] </span><span style="color: #000000;">=</span><span style="color: #000000;"> num[</span><span style="color: #000000;">0</span><span style="color: #000000;">] </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">, i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">; i </span><span style="color: #000000;"><</span><span style="color: #000000;"> n; i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>        {<br>            sum[i] </span><span style="color: #000000;">=</span><span style="color: #000000;"> sum[i</span><span style="color: #000000;">-</span><span style="color: #000000;">1</span><span style="color: #000000;">] </span><span style="color: #000000;">+</span><span style="color: #000000;"> num[i];<br>        }<br>        a </span><span style="color: #000000;">=</span><span style="color: #000000;"> b </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>        que[b</span><span style="color: #000000;">++</span><span style="color: #000000;">] </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;</span><span style="color: #008000;">//</span><span style="color: #008000;">寮濮嬫湁涓兼槸0,闃熷垪閲屽瓨鏀劇殑鏄湁鏁堝拰sum鐨勪笅鏍?nbsp;</span><span style="color: #008000;"><br></span><span style="color: #000000;">        </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">; i </span><span style="color: #000000;"><</span><span style="color: #000000;"> n; i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>        {<br>            </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (; a </span><span style="color: #000000;"><</span><span style="color: #000000;"> b </span><span style="color: #000000;">&&</span><span style="color: #000000;"> que[a] </span><span style="color: #000000;"><</span><span style="color: #000000;"> i </span><span style="color: #000000;">-</span><span style="color: #000000;"> k; a</span><span style="color: #000000;">++</span><span style="color: #000000;">);</span><span style="color: #008000;">//</span><span style="color: #008000;">鍒犻櫎榪囨湡鐨勫鹼紝i-k闄愬畾浜嗘渶澶у彲浠ュ彇k闀垮害 </span><span style="color: #008000;"><br></span><span style="color: #000000;">            ans[i] </span><span style="color: #000000;">=</span><span style="color: #000000;"> que[a];</span><span style="color: #008000;">//</span><span style="color: #008000;">瀵逛簬i緇撳熬鐨刱紿楀彛錛宖[i] = sum[i]-sum[que[a]] </span><span style="color: #008000;"><br></span><span style="color: #000000;">            </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (; a </span><span style="color: #000000;"><</span><span style="color: #000000;"> b </span><span style="color: #000000;">&&</span><span style="color: #000000;"> sum[que[b</span><span style="color: #000000;">-</span><span style="color: #000000;">1</span><span style="color: #000000;">]] </span><span style="color: #000000;">>=</span><span style="color: #000000;"> sum[i]; b</span><span style="color: #000000;">--</span><span style="color: #000000;">);</span><span style="color: #008000;">//</span><span style="color: #008000;">鍒犻櫎鏃犳晥鍊?nbsp;</span><span style="color: #008000;"><br></span><span style="color: #000000;">            que[b</span><span style="color: #000000;">++</span><span style="color: #000000;">] </span><span style="color: #000000;">=</span><span style="color: #000000;"> i; <br>        }<br>        </span><span style="color: #0000ff;">for</span><span style="color: #000000;"> (i </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">, max </span><span style="color: #000000;">=</span><span style="color: #000000;"> </span><span style="color: #000000;">-</span><span style="color: #000000;">230000000</span><span style="color: #000000;">; i </span><span style="color: #000000;"><</span><span style="color: #000000;"> n; i</span><span style="color: #000000;">++</span><span style="color: #000000;">)<br>        {<br>            ksum </span><span style="color: #000000;">=</span><span style="color: #000000;"> sum[i] </span><span style="color: #000000;">-</span><span style="color: #000000;"> sum[ans[i]];<br>            </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (ksum </span><span style="color: #000000;">></span><span style="color: #000000;"> max)<br>            {<br>                max </span><span style="color: #000000;">=</span><span style="color: #000000;"> ksum;<br>                p </span><span style="color: #000000;">=</span><span style="color: #000000;"> i;<br>                len </span><span style="color: #000000;">=</span><span style="color: #000000;"> i </span><span style="color: #000000;">-</span><span style="color: #000000;"> ans[i];<br>            }<br>            </span><span style="color: #0000ff;">else</span><span style="color: #000000;"> </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (ksum </span><span style="color: #000000;">==</span><span style="color: #000000;"> max </span><span style="color: #000000;">&&</span><span style="color: #000000;"> len </span><span style="color: #000000;">></span><span style="color: #000000;"> i </span><span style="color: #000000;">-</span><span style="color: #000000;"> ans[i])<br>            {<br>                p </span><span style="color: #000000;">=</span><span style="color: #000000;"> i;<br>                len </span><span style="color: #000000;">=</span><span style="color: #000000;"> i </span><span style="color: #000000;">-</span><span style="color: #000000;"> ans[i];<br>            }<br>        }<br>        c </span><span style="color: #000000;">=</span><span style="color: #000000;"> ans[p] </span><span style="color: #000000;">+</span><span style="color: #000000;"> </span><span style="color: #000000;">1</span><span style="color: #000000;">;<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (c </span><span style="color: #000000;">></span><span style="color: #000000;"> m)<br>        {<br>            c </span><span style="color: #000000;">-=</span><span style="color: #000000;"> m;<br>        }<br>        </span><span style="color: #0000ff;">if</span><span style="color: #000000;"> (p </span><span style="color: #000000;">></span><span style="color: #000000;"> m)<br>        {<br>            p </span><span style="color: #000000;">-=</span><span style="color: #000000;"> m;<br>        }<br>        printf(</span><span style="color: #000000;">"</span><span style="color: #000000;">%d %d %d\n</span><span style="color: #000000;">"</span><span style="color: #000000;">, max, c, p);<br>    }<br>    system(</span><span style="color: #000000;">"</span><span style="color: #000000;">pause</span><span style="color: #000000;">"</span><span style="color: #000000;">);<br>    </span><span style="color: #0000ff;">return</span><span style="color: #000000;"> </span><span style="color: #000000;">0</span><span style="color: #000000;">;<br>}<br></span></div> <br><br><br><br><br></div> </pre> </div><img src ="http://m.shnenglu.com/Ylemzy/aggbug/134149.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://m.shnenglu.com/Ylemzy/" target="_blank">鐏⒊榛?/a> 2010-11-20 13:17 <a href="http://m.shnenglu.com/Ylemzy/articles/134149.html#Feedback" target="_blank" style="text-decoration:none;">鍙戣〃璇勮</a></div>]]></description></item><item><title>hdu 3356http://m.shnenglu.com/Ylemzy/articles/112955.html鐏⒊榛?/dc:creator>鐏⒊榛?/author>Mon, 19 Apr 2010 02:20:00 GMThttp://m.shnenglu.com/Ylemzy/articles/112955.htmlhttp://m.shnenglu.com/Ylemzy/comments/112955.htmlhttp://m.shnenglu.com/Ylemzy/articles/112955.html#Feedback0http://m.shnenglu.com/Ylemzy/comments/commentRss/112955.htmlhttp://m.shnenglu.com/Ylemzy/services/trackbacks/112955.htmlAir Strike
Problem Description
General Gee is the commander of a military base. He has just received alarming news from one of his spies: the enemy's preparing an air missile strike. The base contains two magnetic towers. When activated and given sufficient power, each of the magnetic towers creates a powerful horizontal magnetic disk. If any missile passes through this disk it deflects away from the base.
Although those towers seem to be an excellent air defense method, there is a problem: The area of the disk generated by a tower is proportional to the amount of energy it receives. The base has enough power plants to generate a certain amount of energy, which has to be divided among those two towers. That means that the total area of the two disks generated from the towers should not exceed the total energy generated by the power plants. Fortunately, the spy was able to know the exact target co-ordinates of the incoming missiles and he reported them to General Gee. The General needs your help in distributing the energy on the two magnetic towers to minimize the number of missiles that will not get deflected by the magnetic towers and therefore will hit the base. You may assume the following:
   1. The towers have different heights and therefore there are no problems associated with the magnetic disks interfering with each other.
   2. A missile will deflect if it passes through the magnetic disk of a tower or even if it just touches its boundary.
   3. A missile hitting a tower (landing exactly on its location) will deflect, even if the tower is not given any energy.
   4. All incoming missiles will go down simultaneously at the exact instant; therefore, there will not be any time available to redistribute the energy amongst the two towers during the strike.
 

Input
Input consists of several test cases. Each test case is specified on N+2 lines. The first line contains an integer (1 <= N <= 1, 000) representing the number of missiles. The second line contains 5 real numbers X1, Y1, X2, Y2 and T: (X1, Y1) is the coordinates of the first tower, (X2, Y2) is the coordinates of the second tower and (0 <= T) is the total amount of energy generated from the power plants (the total area of the two magnetic disks). Each line of the remaining N lines contains two real numbers representing the landing coordinates of a missile.
The absolute value of all the given real numbers is less than or equal to 100 and may include a decimal point followed by up to 3 digits. Any two consecutive numbers on the same line are separated by one or more white-space characters. Zero or more blank lines may appear between test cases.
The last line of the input file is made of a single zero.
 

Output
For each test case, print the following line:
k. M
Where k is the test case number (starting at one,) and M is the minimum number of missiles that will NOT be deflected in the best distribution of energy among the two towers. Use π = 3.141.
Note: There is a blank space before M.
 

Sample Input
6
-3 0 3 0 40.833
-1 4
-2 2.5
1 2
5 2
-4 0
-3 -1
2
0 0 1 1 0
0 0
1 1
0
 

Sample Output
1. 2
2. 0
#include<stdio.h>
#include
<stdlib.h>
#define maxn 1000
#define PI 3.141
const double inf = 0.00001;
double d1[maxn], d2[maxn];
double dis(double x1, double y1, double x2, double y2)
{
    
return 1.0 * (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2);
}
int main()
{
    
int n, i, j, ans, sum, k = 0;
    
double r1, r2, r3, r4, r;
    
double x1, y1, x2, y2, x, y;
    
while (scanf("%d"&n), n)
    {
        scanf(
"%lf%lf%lf%lf%lf"&x1, &y1, &x2, &y2, &r);
        r 
= 1.0 * r / PI;
        
for (i = 0; i < n; i++)
        {
            scanf(
"%lf%lf"&x, &y);
            d1[i] 
= dis(x, y, x1, y1);
            d2[i] 
= dis(x, y, x2, y2);
        }
        
for (i = 0, ans = n; i < n; i++)
        {
            r1 
= d1[i];
            
if (r1 <= r)//鏋氫婦涓涓偣鍜屽叾涓竴涓鐨勮窛紱籸1,鍒欏墿涓嬬殑紓佹嘗璺濈涓簉2
            {
                r2 
= r - r1;
                
for (j = 0, sum = 0; j < n; j++)
                {
                    
if (d1[j] <= r1)
                    {
                        sum
++;
                    }
                    
else if (d2[j] <= r2)
                    {
                        sum
++;
                    }
                }
                
if (ans > n - sum)
                {
                    ans 
= n - sum;
                }
            }
            r2 
= d2[i];
            
if (r2 <= r)
            {
                r1 
= r - r2;
                
for (j = 0, sum = 0; j < n; j++)
                {
                    
if (d1[j] <= r1)
                    {
                        sum
++;
                    }
                    
else if (d2[j] <= r2)
                    {
                        sum
++;
                    }
                }
                
if (ans > n - sum)
                {
                    ans 
= n - sum;
                }
            }
            
        }
        k
++;
        printf(
"%d. %d\n", k, ans);
    }
    
return 0;
}




]]>
hdu 3355 騫挎悳http://m.shnenglu.com/Ylemzy/articles/112866.html鐏⒊榛?/dc:creator>鐏⒊榛?/author>Sat, 17 Apr 2010 13:02:00 GMThttp://m.shnenglu.com/Ylemzy/articles/112866.htmlhttp://m.shnenglu.com/Ylemzy/comments/112866.htmlhttp://m.shnenglu.com/Ylemzy/articles/112866.html#Feedback0http://m.shnenglu.com/Ylemzy/comments/commentRss/112866.htmlhttp://m.shnenglu.com/Ylemzy/services/trackbacks/112866.htmlHop 鈥?Don’t Walk!
Problem Description
KERMIT THE FROG is a classic video game with a simple control and objective but requires a good deal of thinking.
You control an animated frog that can walk and hop, in both forward and backward directions. The frog stands in a space between an otherwise a contiguous line of tiles. Each tile is painted black on one side, and white on the other. The frog can walk (forward, or backward) over an adjacent tile (in front or behind him.)
When the frog walks over a tile, the tile slides to the space where the frog was standing. For example, in the adjacent figure, the frog has two tiles behind him, and three in front. We’ll use the notation BWFBBW to refer to this situation where F refers to the space (where the frog is standing,) B is a tile with its black face showing, while W is a tile with its white face showing. The forward direction is from left to right. If the frog were to walk forward, the resulting situation is BWBFBW. Similar behavior when the frog walks backward, the tile behind the frog slides to where the frog was standing. The frog can also hop over the tiles. The frog can hop over an adjacent tile landing on the tile next to it. For example, if the frog was to hop backward, it would land on the first (left-most) tile, and the tile would jump to the space where the frog was standing. In addition, the tile would flip sides. For example, hopping backward in the figure would result in the situation: FWWBBW. We challenge you to write a program to determine the minimum number of moves (walks or hops) to transform one tile configuration into another.

 

Input
Your program will be tested on one or more test cases. Each test case is specified on a single line that specifies string S representing the initial tile arrangement. S is a non-empty string and no longer than 100 characters and is made of the letters ’B’, ’W’, and exactly one ’F’. The last line of the input file has one or more ’-’ (minus) characters.
 

Output
For each test case, print the following line:
k. M
Where k is the test case number (starting at one,) and M is the minimum number of moves needed to transform the given arrangement to an arrangement that has no white tile(s) between any of its black tiles . The frog can be anywhere. M is -1 if the problem cannot be solved in less than 10 moves.
Note: There is a blank space before M.
 

Sample Input
WWBBFBW
WWFBWBW
FWBBWBW
---

 

Sample Output
1. 0
2. 1
3. 2

棰樻剰錛氶潚铔欏彲鍚戝墠鎴栧悜鍚庤蛋涓姝ワ紝璧板悗錛岄潚铔欐墍鍦ㄤ綅緗殑鐮栨粦鍒伴潚铔欐病璺沖墠鐨勪綅緗傞潚铔欎篃鍙互鍚戝墠璺蟲垨鍚戝悗璺籌紝璺充竴嬈¤兘璺寵繃2涓爾錛?br>
闈掕洐鎵鍦ㄤ綅緗殑鐮栫炕杞悗婊戝埌闈掕洐娌¤煩鍓嶇殑浣嶇疆銆傛眰闈掕洐鍦ㄥ崄涓姩浣滀箣鍐咃紝浣夸換鎰忎袱涓粦鐮栦箣闂存病鐧界爾鐨勬渶灝忔鏁般?br>
#include<stdio.h>
#include<string.h>
#define maxn 300000
int ans, len;
char state[maxn][100];
char step[maxn], f[maxn];
int check(int depth)
{
    int i, j, x, y;
    for (i = 0, j = len - 1, x = y = -1; i < len; i++, j--)
    {
        if (state[depth][i] == 'B' && x == -1)
        {
            x = i;
        }
        if (state[depth][j] == 'B' && y == -1)
        {
            y = j;
        }
    }
    if (x != -1 && y != -1)
    {
        for (i = x + 1; i < y; i++)
        {
            if (state[depth][i] == 'W')
            {
                return 0;
            }
        }
    }
    return 1;
}
void swap(int depth, int i, int j)
{
    state[depth][i] ^= state[depth][j];
    state[depth][j] ^= state[depth][i];
    state[depth][i] ^= state[depth][j];
}
void hopf(int depth, int i)
{
    swap(depth, i, i + 2);
    state[depth][i] = (state[depth][i] == 'B') ? 'W' : 'B' ;
}
void hopb(int depth, int i)
{
    swap(depth, i, i - 2);
    state[depth][i] = (state[depth][i] == 'B') ? 'W' : 'B' ;
}
void bfs()
{
    int head = 0, tial = 1, h;
    if (check(0))
    {
        ans = 0;
        return;
    }
    while (head < tial)
    {
        if (step[head] >= 9)
        {
            return;
        }
        h = f[head];
        if (h + 1 < len)
        {        
            strcpy(state[tial], state[head]);
            swap(tial, h, h + 1);
            step[tial] = step[head] + 1;
            f[tial] = h + 1;
            if (check(tial))
            {
                ans = step[tial];
                return;
            }
            tial++;
        }
        if (h - 1 >= 0)
        {
            strcpy(state[tial], state[head]);
            swap(tial, h, h - 1);
            step[tial] = step[head] + 1;
            f[tial] = h - 1;
            if (check(tial))
            {
                ans = step[tial];
                return;
            }
            tial++;
        }
        if (h + 2 < len)
        {
            strcpy(state[tial], state[head]);
            hopf(tial, h);
            step[tial] = step[head] + 1;
            f[tial] = h + 2;
            if (check(tial))
            {
                ans = step[tial];
                return;
            }
            tial++;
        }
        if (h - 2 >= 0)
        {
            strcpy(state[tial], state[head]);
            hopb(tial, h);
            step[tial] = step[head] + 1;
            f[tial] = h - 2;
            if (check(tial))
            {
                ans = step[tial];
                return;
            }
            tial++;
        }
        head++;
    }
}
int main()
{
    int i, j, k = 0;
    char s[100];
    while (scanf("%s", s), s[0] != '-')
    {
        k++;
        ans = 10;
        for (i = 0; (state[0][i] = s[i]) != 0; i++)
        {
            if (s[i] == 'F')
            {
                j = i;
            }
        }
        len = i;
        strcpy(state[0], s);
        step[0] = 0;
        f[0] = j;
        bfs();        
        printf("%d. %d\n", k, ans < 10 ? ans : -1);
    }
}









]]>
青青草原综合久久大伊人导航_色综合久久天天综合_日日噜噜夜夜狠狠久久丁香五月_热久久这里只有精品
  • <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>
            亚洲女同同性videoxma| 亚洲毛片视频| 久久综合一区二区| 亚洲综合欧美日韩| 夜夜夜久久久| 在线亚洲欧美专区二区| 日韩午夜电影av| 亚洲经典三级| 蜜月aⅴ免费一区二区三区| 欧美一进一出视频| 午夜精品国产精品大乳美女| av成人手机在线| 亚洲中字在线| 久久精品国产欧美激情| 狼人天天伊人久久| 狠狠综合久久| 欧美激情乱人伦| 久久超碰97中文字幕| 99精品国产在热久久婷婷| 99精品热视频| 国产精品国产三级国产普通话三级 | 午夜精品久久久久久久白皮肤| 亚洲美女视频| 欧美国产亚洲精品久久久8v| 欧美日韩伦理在线| 久久国产日本精品| 欧美电影免费观看高清| 亚洲男人的天堂在线aⅴ视频| 在线欧美日韩国产| 久久激情婷婷| 久久久久99| 亚洲丁香婷深爱综合| 一本色道**综合亚洲精品蜜桃冫| 在线观看av一区| 亚洲六月丁香色婷婷综合久久| 激情五月婷婷综合| 欧美三级视频| 美女精品一区| 午夜精品久久久久久久男人的天堂| 亚洲第一页在线| 在线精品福利| 欧美一级电影久久| 国产精品麻豆成人av电影艾秋| 亚洲国产精品一区二区第四页av| 久久久久免费视频| 久久国产欧美精品| 久久亚洲一区| 欧美色中文字幕| 欧美色图首页| 国户精品久久久久久久久久久不卡| 国产免费成人| 美女在线一区二区| 欧美色另类天堂2015| 亚洲黄页视频免费观看| 亚洲精品一区二区在线| 亚洲一区二区在线观看视频| 黄色日韩网站| 国产在线成人| 国产日产欧美精品| 激情五月***国产精品| 国产精品久久久久久久久果冻传媒| 国产欧美1区2区3区| 欧美日韩美女| 加勒比av一区二区| 99精品免费| 欧美中文字幕不卡| 欧美精品日韩精品| 国产亚洲成av人在线观看导航 | 欧美性理论片在线观看片免费| 亚洲先锋成人| 亚洲免费在线观看视频| 久久综合给合久久狠狠狠97色69| 亚洲精品欧洲精品| 亚洲一级片在线观看| 性欧美精品高清| 亚洲国产日本| 久久久久一区二区| 国产亚洲欧美日韩美女| 在线日韩av片| 欧美在线日韩| 亚洲精选视频免费看| 欧美激情导航| 在线精品国精品国产尤物884a| 日韩小视频在线观看专区| 久久激情五月婷婷| 亚洲女同同性videoxma| 欧美日韩国产综合视频在线观看中文| 亚洲高清精品中出| 欧美成人激情在线| 欧美主播一区二区三区美女 久久精品人| 久久综合狠狠| 欧美精品一二三| 91久久在线视频| 欧美国产1区2区| 欧美专区日韩专区| 欧美性jizz18性欧美| 亚洲精品无人区| 欧美激情一区二区三区高清视频 | 欧美一区二区视频网站| 国产欧美日韩伦理| 欧美在线视频一区二区三区| 亚洲欧美电影院| 韩国一区二区三区美女美女秀| 蜜桃av一区二区三区| 麻豆成人综合网| 日韩视频国产视频| 一个色综合av| 国产亚洲亚洲| 欧美韩日视频| 国产精品mm| 久久一区免费| 欧美日韩亚洲天堂| 久久av红桃一区二区小说| 久久成人国产精品| 日韩一级黄色大片| 亚洲欧美综合国产精品一区| 亚洲第一搞黄网站| 亚洲裸体俱乐部裸体舞表演av| 国产精品亚洲欧美| 欧美成人激情视频| 国产精品久久看| 男女精品视频| 国产精品日日摸夜夜摸av| 欧美大色视频| 国产精品一区二区久久久久| 欧美成人综合网站| 欧美a级在线| 亚洲欧美日韩在线综合| 久久只有精品| 亚洲欧美日韩一区二区| 麻豆久久精品| 午夜精品视频一区| 亚洲精品一区二区网址| 久久久成人精品| 欧美激情一区二区三区在线视频| 午夜精品久久| 欧美丰满少妇xxxbbb| 久久国内精品视频| 欧美日韩国产综合网| 欧美18av| 国产精品一二三视频| 亚洲电影在线看| 黄色亚洲在线| 亚洲一区亚洲二区| 一区二区三区高清视频在线观看| 久久九九免费| 久久精品人人做人人综合| 欧美性大战久久久久久久| 亚洲国产日韩一区| 亚洲国产一区二区三区a毛片| 欧美在线视频免费| 久久久久久久一区二区三区| 国产精品免费小视频| 一级日韩一区在线观看| 99国产精品私拍| 欧美成人资源网| 欧美激情麻豆| 亚洲区第一页| 免费欧美在线| 欧美黄污视频| 亚洲国产综合在线| 麻豆91精品| 免费亚洲婷婷| 在线欧美日韩精品| 久久综合综合久久综合| 欧美成人精品激情在线观看| 精品二区视频| 久久综合中文色婷婷| 欧美激情视频一区二区三区免费 | 亚洲欧美国产精品专区久久| 欧美精品自拍偷拍动漫精品| 欧美激情bt| 99精品欧美一区| 欧美日韩一区二区在线观看视频| 亚洲免费观看视频| 亚洲午夜小视频| 国产精品一区二区黑丝| 新片速递亚洲合集欧美合集| 久久久精品日韩| 一区国产精品| 欧美精品亚洲一区二区在线播放| 亚洲美女啪啪| 亚洲一区在线直播| 国产精品美女午夜av| 一本色道久久综合| 在线观看欧美日韩国产| 久久久91精品国产一区二区精品| 性欧美超级视频| 国内视频精品| 欧美1区2区3区| 欧美国产三级| 亚洲欧洲日韩在线| 久久久精品网| 欧美大片免费| av不卡在线观看| 国产欧美短视频| 久久久精品网| 欧美一级播放| 亚洲欧美综合另类中字| 香蕉尹人综合在线观看|