• <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>

            學習心得(code)

            superlong@CoreCoder

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              74 Posts :: 0 Stories :: 5 Comments :: 0 Trackbacks

            公告

            文字可能放在http://blog.csdn.net/superlong100,此處存放代碼

            常用鏈接

            留言簿(4)

            我參與的團隊

            搜索

            •  

            最新隨筆

            最新評論

            • 1.?re: Poj 1279
            • 對于一個凹多邊形用叉積計算面積 后能根據結果的正負來判斷給的點集的時針方向?
            • --bsshanghai
            • 2.?re: Poj 3691
            • 你寫的這個get_fail() 好像并是真正的get_fail,也是說fail指向的串并不是當前結點的子串。為什么要這樣弄呢?
            • --acmer1183
            • 3.?re: HDU2295[未登錄]
            • 這個是IDA* 也就是迭代加深@ylfdrib
            • --superlong
            • 4.?re: HDU2295
            • 評論內容較長,點擊標題查看
            • --ylfdrib
            • 5.?re: HOJ 11482
            • 呵呵..把代碼發在這里很不錯..以后我也試試...百度的編輯器太爛了....
            • --csuft1

            閱讀排行榜

            評論排行榜


            #include <stdio.h>
            #include 
            <ctime>
            #include 
            <stdlib.h>
            #include 
            <string.h>

            const int SIZE = 16;
            const int N = SIZE*SIZE*SIZE;
            const int M = SIZE*SIZE*4;
            const char LET = 'A';

            char map[SIZE+1][SIZE+1];
            int L[N*M+1], R[N*M+1], U[N*M+1], D[N*M+1], Sum[N*M+1];
            int x[5], lenx;
            int Row[N*M+1], Col[N*M+1];
            int ans[N+1], anslen;
            int id;
            bool OK;

            void pre() {
                
            for(int i = 0; i <= M; i ++) {
                    L[i] 
            = i - 1;
                    R[i] 
            = i + 1;
                    U[i] 
            = D[i] = i;
                    Sum[i] 
            = 0;
                }
                L[
            0= M; R[M] = 0;
                id 
            = M + 1;
            }

            inline 
            void insert(int i, int *xx) {
                
            for(int j = 0; j < lenx; j ++, id ++) {
                    
            int x = xx[j]+1;
                    Row[id] 
            = i;
                    Col[id] 
            = x;
                    Sum[x] 
            ++;
                    U[id] 
            = x;
                    D[id] 
            = D[x];
                    U[D[x]] 
            = id;
                    D[x] 
            = id;
                    
            if( j == 0 ) {
                        L[id] 
            = R[id] = id;
                    } 
            else {
                        L[id] 
            = id - 1;
                        R[id] 
            = id - j;
                        R[id
            -1= id;
                        L[id
            -j] = id;
                    }
                }
            }

            void build() {
                
            for(int i = 0; i < SIZE; i ++) {
                    
            for(int j = 0; j < SIZE; j ++) {
                        
            for(int k = 0; k < SIZE; k ++) {
                            
            int row = k+SIZE*j+SIZE*SIZE*i+1;
                            lenx 
            = 0;
                            
            if( map[i][j] == '-' || map[i][j] == k + 'A' ) {
                                x[lenx
            ++= SIZE*+ k;
                                x[lenx
            ++= SIZE*SIZE + SIZE*+ k;
                                
            int temp = (i / 4* 4 + j / 4;
                                x[lenx
            ++= 2*SIZE*SIZE + temp * SIZE + k;
                                x[lenx
            ++= 3*SIZE*SIZE + i*SIZE + j;
                                insert(row, x);
                            }
                        }
                    }
                }
            }

            inline 
            void remove(int c) {
                R[L[c]] 
            = R[c];
                L[R[c]] 
            = L[c];
                
            for(int id = D[c]; id != c; id = D[id]) {
                    
            for(int i = R[id]; i != id; i = R[i] ) {
                        D[U[i]] 
            = D[i];
                        U[D[i]] 
            = U[i];
                        Sum[Col[i]] 
            --;
                    }
                }
            }

            inline 
            void resume(int c) {
                L[R[c]] 
            = c;
                R[L[c]] 
            = c;
                
            for(int id = D[c]; id != c; id = D[id]) {
                    
            for(int i = R[id]; i != id; i = R[i] ) {
                        U[D[i]] 
            = i;
                        D[U[i]] 
            = i;
                        Sum[Col[i]] 
            ++;
                    }
                }
            }

            bool dfs(int deep) {
                
            if( R[0== 0 ) return true;
                
            int column = R[0];
                
            for(int i = R[0]; i != 0; i = R[i]) {
                    
            if( Sum[i] < Sum[column] ) {
                        column 
            = i;
                        
            if( Sum[column] < 2 ) break;
                    }
                }
                remove(column);
                
            for(int id = D[column]; id != column; id = D[id]) {
                    ans[deep] 
            = Row[id];
                    
            for(int i = R[id]; i != id; i = R[i]) remove(Col[i]);
                    
            if( dfs( deep + 1) ) return true;
                    
            for(int i = L[id]; i != id; i = L[i]) resume(Col[i]);
                }
                resume(column);
                
            return false;
            }


            int main() {
                freopen(
            "in.txt","r",stdin);
                
            while( scanf("%s", map[0]) != EOF ) {
                    
            for(int i = 1; i < SIZE; i ++) scanf("%s", map[i]);
                    pre();
                    build();
                    dfs(
            0);
                    
            for(int i = 0; i < 256; i ++) {
                        
            int r = (ans[i] - 1/ SIZE / SIZE % SIZE;
                        
            int c = (ans[i] - 1/ SIZE % SIZE;
                        
            int val = (ans[i] - 1% SIZE;
                        map[r][c] 
            = val + 'A';
                    }
                    
            for(int i = 0; i < SIZE; i ++){ 
                        
            for(int j = 0; j < SIZE; j ++) printf("%c",map[i][j]);
                        printf(
            "\n");
                    }
                    printf(
            "\n");
                }
                
            while(1);
            }


            http://acm.pku.edu.cn/JudgeOnline/problem?id=3076

            posted on 2010-08-09 18:39 superlong 閱讀(543) 評論(0)  編輯 收藏 引用
            一本久久综合亚洲鲁鲁五月天| 久久无码高潮喷水| 青青青国产成人久久111网站| 欧美精品一区二区精品久久| 久久久无码精品亚洲日韩软件| 97视频久久久| 国内精品伊人久久久久网站| 四虎国产精品成人免费久久| 99久久国产热无码精品免费| 天天做夜夜做久久做狠狠| 久久久久99精品成人片欧美| 久久久久亚洲精品中文字幕| 精品无码久久久久久午夜| 亚洲国产成人精品女人久久久| 久久久久女人精品毛片| 久久婷婷五月综合国产尤物app| 久久国产精品-国产精品| 亚洲va中文字幕无码久久不卡| 久久亚洲中文字幕精品一区| 999久久久免费精品国产| 伊人久久大香线蕉成人| 久久国产成人| 久久亚洲国产精品一区二区| 久久人人爽人人爽人人片AV不 | 人妻少妇精品久久| 久久国产乱子伦精品免费强| 伊人久久大香线蕉亚洲五月天| 色播久久人人爽人人爽人人片aV| 久久九九青青国产精品| 国产精品免费看久久久| 欧美伊人久久大香线蕉综合| 欧美与黑人午夜性猛交久久久 | 久久香蕉超碰97国产精品| 国产精品久久久香蕉| 日韩十八禁一区二区久久| 一级做a爰片久久毛片人呢| 人妻无码中文久久久久专区| 无码人妻少妇久久中文字幕 | 欧美亚洲另类久久综合婷婷| 久久久久97国产精华液好用吗| 精品久久人人爽天天玩人人妻|