• <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>
            心如止水
            Je n'ai pas le temps
            posts - 400,comments - 130,trackbacks - 0
            DP題,狀態總量為2^12,其實可以用對稱性減少一半狀態數。
            以下是我的代碼:
            /*
             * Author:  lee1r
             * Created Time:  2011/8/3 12:18:41
             * File Name: uva10651.cpp
             
            */
            #include
            <iostream>
            #include
            <sstream>
            #include
            <fstream>
            #include
            <vector>
            #include
            <list>
            #include
            <deque>
            #include
            <queue>
            #include
            <stack>
            #include
            <map>
            #include
            <set>
            #include
            <bitset>
            #include
            <algorithm>
            #include
            <cstdio>
            #include
            <cstdlib>
            #include
            <cstring>
            #include
            <cctype>
            #include
            <cmath>
            #include
            <ctime>
            #define L(x) ((x)<<1)
            #define R(x) (((x)<<1)+1)
            #define Half(x) ((x)>>1)
            #define lowbit(x) ((x)&(-(x)))
            using namespace std;
            const int kInf(0x7f7f7f7f);
            const double kEps(1e-11);
            typedef 
            long long int64;
            typedef unsigned 
            long long uint64;

            int d[4107];

            int dp(int x)
            {
                
            if(d[x]!=-1)
                    
            return d[x];
                d[x]
            =0;
                
            for(int i=0;i<12;i++)
                    
            if(x&(1<<i))
                        d[x]
            ++;
                
            for(int i=0;i<10;i++)
                    
            if((x&(1<<i)) && (x&(1<<(i+1))) && !(x&(1<<(i+2))))
                    {
                        
            int newx(x);
                        newx
            =(~((~newx)|(1<<i)));
                        newx
            =(~((~newx)|(1<<(i+1))));
                        newx
            =(newx|(1<<(i+2)));
                        d[x]
            =min(d[x],dp(newx));
                    }
                
            for(int i=0;i<10;i++)
                    
            if(!(x&(1<<i)) && (x&(1<<(i+1))) && (x&(1<<(i+2))))
                    {
                        
            int newx(x);
                        newx
            =(~((~newx)|(1<<(i+1))));
                        newx
            =(~((~newx)|(1<<(i+2))));
                        newx
            =(newx|(1<<i));
                        d[x]
            =min(d[x],dp(newx));
                    }
                
            return d[x];
            }

            int main()
            {
                
            //freopen("data.in","r",stdin);
                
                memset(d,
            -1,sizeof(d));
                
                
            int T;
                cin
            >>T;
                
            while(T--)
                {
                   
            string s;
                   cin
            >>s;
                   
            int n(0);
                   
            for(int i=0;i<s.size();i++)
                       
            if(s[i]=='o')
                           n
            =(n|(1<<i));
                   printf(
            "%d\n",dp(n));
                }
                
                
            return 0;
            }
            posted on 2011-08-03 19:27 lee1r 閱讀(365) 評論(0)  編輯 收藏 引用 所屬分類: 題目分類:動態規劃
            国产精品亚洲综合专区片高清久久久| 一本久久知道综合久久| 99久久综合狠狠综合久久| 激情五月综合综合久久69| 午夜福利91久久福利| 欧美噜噜久久久XXX| 久久综合九色综合久99| 一本久久a久久精品综合香蕉| 新狼窝色AV性久久久久久| 国产激情久久久久影院小草| 中文字幕亚洲综合久久菠萝蜜| 日日噜噜夜夜狠狠久久丁香五月| 狠狠色丁香久久综合五月| 久久久久国产精品人妻| 91精品国产91久久久久久青草 | 久久99精品国产99久久| 久久青青国产| 青青草国产精品久久久久| 中文字幕乱码久久午夜| 久久国产一片免费观看| 久久99国产精品久久99| 久久亚洲AV成人出白浆无码国产| 色婷婷久久久SWAG精品| 国产亚洲色婷婷久久99精品91 | 国产精品免费久久久久影院| 久久国产精品一国产精品金尊| 一本色道久久88精品综合| 日本欧美国产精品第一页久久| 99久久无码一区人妻| 久久福利青草精品资源站免费| 久久天天躁狠狠躁夜夜躁2O2O| 亚洲日本va中文字幕久久| 久久久久久精品无码人妻| 一本大道久久香蕉成人网| 国产精品成人久久久| 国内精品久久国产| 狠狠色丁香久久婷婷综合| 伊人久久大香线蕉综合影院首页 | 午夜肉伦伦影院久久精品免费看国产一区二区三区 | 狠狠久久亚洲欧美专区| 好久久免费视频高清|