锘??xml version="1.0" encoding="utf-8" standalone="yes"?>亚洲国产精久久久久久久,久久午夜综合久久,久久精品成人欧美大片http://www.shnenglu.com/Yusi-Xiao/category/9924.htmlzh-cnSat, 11 Apr 2009 21:31:52 GMTSat, 11 Apr 2009 21:31:52 GMT60POJ 1475 瑙i鎬濊礬http://www.shnenglu.com/Yusi-Xiao/archive/2009/04/10/79556.html鑲栫窘鎬?/dc:creator>鑲栫窘鎬?/author>Fri, 10 Apr 2009 14:36:00 GMThttp://www.shnenglu.com/Yusi-Xiao/archive/2009/04/10/79556.htmlhttp://www.shnenglu.com/Yusi-Xiao/comments/79556.htmlhttp://www.shnenglu.com/Yusi-Xiao/archive/2009/04/10/79556.html#Feedback0http://www.shnenglu.com/Yusi-Xiao/comments/commentRss/79556.htmlhttp://www.shnenglu.com/Yusi-Xiao/services/trackbacks/79556.html鍩烘湰鎬濊礬濡備笅:
1.絎竴閲岯FS鏍規(guī)嵁綆卞瓙鍙Щ鍔ㄧ殑浣嶇疆榪涜BFS.
2.絎簩閲嶅皢綆卞瓙鐩墠鎵鍦ㄧ殑浣嶇疆璁句負(fù)涓嶅彲杈?鏍規(guī)嵁綆卞瓙鎵鍦ㄧ殑浣嶇疆寰楀嚭浜烘墍搴旇鍦ㄧ殑浣嶇疆,鏍規(guī)嵁姝や綅緗浜鴻繘琛屼簡BFS.
鍗沖彲.

]]>
POJ 1517 瑙i鎶ュ憡http://www.shnenglu.com/Yusi-Xiao/archive/2009/04/10/79553.html鑲栫窘鎬?/dc:creator>鑲栫窘鎬?/author>Fri, 10 Apr 2009 14:21:00 GMThttp://www.shnenglu.com/Yusi-Xiao/archive/2009/04/10/79553.htmlhttp://www.shnenglu.com/Yusi-Xiao/comments/79553.htmlhttp://www.shnenglu.com/Yusi-Xiao/archive/2009/04/10/79553.html#Feedback0http://www.shnenglu.com/Yusi-Xiao/comments/commentRss/79553.htmlhttp://www.shnenglu.com/Yusi-Xiao/services/trackbacks/79553.html
Code


]]>
POJ 2965 瑙i鎶ュ憡http://www.shnenglu.com/Yusi-Xiao/archive/2009/03/21/77385.html鑲栫窘鎬?/dc:creator>鑲栫窘鎬?/author>Sat, 21 Mar 2009 03:11:00 GMThttp://www.shnenglu.com/Yusi-Xiao/archive/2009/03/21/77385.htmlhttp://www.shnenglu.com/Yusi-Xiao/comments/77385.htmlhttp://www.shnenglu.com/Yusi-Xiao/archive/2009/03/21/77385.html#Feedback0http://www.shnenglu.com/Yusi-Xiao/comments/commentRss/77385.htmlhttp://www.shnenglu.com/Yusi-Xiao/services/trackbacks/77385.html  1 #include <iostream>  2 #incl...  闃呰鍏ㄦ枃

]]>
POJ 1753 瑙i鎶ュ憡http://www.shnenglu.com/Yusi-Xiao/archive/2009/03/21/77383.html鑲栫窘鎬?/dc:creator>鑲栫窘鎬?/author>Sat, 21 Mar 2009 02:30:00 GMThttp://www.shnenglu.com/Yusi-Xiao/archive/2009/03/21/77383.htmlhttp://www.shnenglu.com/Yusi-Xiao/comments/77383.htmlhttp://www.shnenglu.com/Yusi-Xiao/archive/2009/03/21/77383.html#Feedback0http://www.shnenglu.com/Yusi-Xiao/comments/commentRss/77383.htmlhttp://www.shnenglu.com/Yusi-Xiao/services/trackbacks/77383.html
鐢ㄤ綅鎿嶄綔+BFS瑙e喅.鍩烘湰鎬濇兂濡備笅:
緇欐鐩樻瘡涓涓姸鎬佽祴浜堜竴涓姸鎬乮d,id璁$畻鏂規(guī)硶鏄皢媯嬬洏涓庢暟鐨勪簩榪涘埗琛ㄧず鑱旂郴璧鋒潵,濡傞鎵緇欑殑鏁版嵁:
bwwb
bbwb
bwwb
bwww
鐘舵乮d涓?585,璁$畻鏂規(guī)硶涓?*2^0+0*2^1+1*2^2..1*2^12+0*2^13..=6585(鍏朵腑b浠h〃1,w浠h〃0)
鍦ㄦ鍩虹涓婅繘琛孊FS鎼滅儲,棣栧厛鐞嗚В涓鐐?鍏堢偣(0,0)鍐嶇偣(0,1)涓庡厛鐐?0,1)鍐嶇偣(0,0)瀵圭粨鏋滀笉閫犳垚浠諱綍褰卞搷.鍥犳閬嶅巻媯嬬洏鐨?6涓綅緗?灝嗘瘡嬈$偣鍑誨悗鐨勭姸鎬乮d鍒╃敤鏍?wèi)鐘毒l撴瀯淇濆瓨.濡?
                                 6585
                               /   |   \  ...
                           (0,0) (0,1)  (0,2)
                            /      |      \  ...
                         6568     6553     6646
                      ...............................
瀵規(guī)鏍?wèi)杩涜BFS鎼滅儲,灝唅d涓?(鍏ㄧ櫧)鎴?5535(鍏ㄩ粦)鐨勬椂鍊欏垯鎼滅儲鎴愬姛,杈撳嚭鏍?wèi)鐨勯珮搴?鍚﹀垯杈撳嚭"Impossible".
涓轟簡鎻愰珮鎼滅儲鏁堢巼,閲囩敤浣嶈繍綆?濡傛灉鎯沖皢鏁存暟鐨勪簩榪涘埗鏌愪竴浣嶇炕杞彲閲囩敤id^=(1<<x)(x浠h〃瑕佺炕杞殑浣嶇疆)
 1 #include "assert.h"
 2 #include <iostream>
 3 #include <queue>
 4 using namespace std;
 5 
 6 const int MAX_STATE = 65536;
 7 const int ALL_WHILE_STATE = 0;
 8 const int ALL_BLACK_STATE = 65535;
 9 const int WIDTH_OF_BOARD = 4;
10 const int SIZE_OF_BOARD = WIDTH_OF_BOARD * WIDTH_OF_BOARD; // 4 * 4
11 
12 int ConvertPieceColorToInt(char color)
13 {
14     switch(color)
15     {
16     case 'b':
17         return 1;
18     case 'w':
19         return 0;
20     }
21 }
22 
23 int FlipPiece(int state_id, int position)
24 {
25     state_id ^= (1 << position);
26 
27     // up
28     if(position - 4 >= 0)
29         state_id ^= (1 << (position - 4));
30     // down
31     if(position + 4 < SIZE_OF_BOARD)
32         state_id ^= (1 << (position + 4));
33     // left
34     if(position % 4 != 0)
35         state_id ^= (1 << (position - 1));
36     // right
37     if(position % 4 != 3)
38         state_id ^= (1 << (position + 1));
39 
40     return state_id;
41 }
42 
43 int _tmain(int argc, _TCHAR* argv[])
44 {
45     int current_state_id = 0;
46     int state[MAX_STATE];
47     queue<int> search_queue;
48 
49     memset(state, -1sizeof(state));
50 
51     char color;
52 
53     for(int i = 0; i < SIZE_OF_BOARD; ++i)
54     {
55         cin >> color;
56         current_state_id += ConvertPieceColorToInt(color) << i;
57     }
58 
59     if(current_state_id == ALL_WHILE_STATE
60         || current_state_id == ALL_BLACK_STATE)
61     {
62         cout << "0" << endl;
63         return 0;
64     }
65 
66     state[current_state_id] = 0;
67     search_queue.push(current_state_id);
68 
69     int next_state_id;
70 
71     while(!search_queue.empty())
72     {
73         current_state_id = search_queue.front();
74         search_queue.pop();
75 
76         for(int i = 0; i < SIZE_OF_BOARD; ++i)
77         {
78             next_state_id = FlipPiece(current_state_id, i);
79             if(next_state_id == ALL_WHILE_STATE
80                 || next_state_id == ALL_BLACK_STATE)
81             {
82                 cout << state[current_state_id] + 1 << endl;
83                 return 0;
84             }
85             assert(next_state_id < MAX_STATE);
86             if(state[next_state_id] == -1 /* not visited */)
87             {
88                 state[next_state_id] = state[current_state_id] + 1;
89                 search_queue.push(next_state_id);
90             }
91         }
92     }
93 
94     cout << "Impossible" << endl;
95     return 0;
96 }
97 
98 



]]>
A级毛片无码久久精品免费| 国产成人久久精品麻豆一区| 久久国产欧美日韩精品免费| 亚洲国产精久久久久久久| 久久精品夜色噜噜亚洲A∨| 久久综合成人网| 久久综合噜噜激激的五月天| 国产福利电影一区二区三区久久老子无码午夜伦不 | 99久久香蕉国产线看观香| 久久久久亚洲AV无码专区体验| 99久久精品国产一区二区| 久久精品国产清自在天天线| 91精品国产91热久久久久福利 | 7国产欧美日韩综合天堂中文久久久久| 香蕉99久久国产综合精品宅男自 | 久久久久这里只有精品| 亚洲AV无码久久精品蜜桃| 国产精品熟女福利久久AV| 亚洲欧美成人综合久久久| 久久这里有精品视频| 国产高清国内精品福利99久久| 人妻无码αv中文字幕久久| 亚洲AV伊人久久青青草原| 国产高潮国产高潮久久久91 | 国产精品久久久久…| 亚洲国产成人精品91久久久| 一本久久久久久久| 日本久久久久久中文字幕| 精品久久人妻av中文字幕| 色综合久久综合中文综合网| 一本一道久久a久久精品综合 | 久久亚洲综合色一区二区三区| 亚洲精品无码久久千人斩| 国产精品久久婷婷六月丁香| 久久精品国产国产精品四凭| 91精品国产高清久久久久久91| 国产成人无码久久久精品一| 久久精品99久久香蕉国产色戒| 精品少妇人妻av无码久久| 久久精品国产99国产精品澳门 | 久久久久久久尹人综合网亚洲|