• <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>
            隨筆 - 87  文章 - 279  trackbacks - 0
            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            潛心看書研究!

            常用鏈接

            留言簿(19)

            隨筆分類(81)

            文章分類(89)

            相冊

            ACM OJ

            My friends

            搜索

            •  

            積分與排名

            • 積分 - 216441
            • 排名 - 117

            最新評論

            閱讀排行榜

            評論排行榜

            Bugs Integrated, Inc.
            Time Limit:15000MS  Memory Limit:30000K
            Total Submit:1180 Accepted:309
            Case Time Limit:5000MS

            Description
            Bugs Integrated, Inc. is a major manufacturer of advanced memory chips. They are launching production of a new six terabyte Q-RAM chip. Each chip consists of six unit squares arranged in a form of a 2*3 rectangle. The way Q-RAM chips are made is such that one takes a rectangular plate of silicon divided into N*M unit squares. Then all squares are tested carefully and the bad ones are marked with a black marker.


            Finally, the plate of silicon is cut into memory chips. Each chip consists of 2*3 (or 3*2) unit squares. Of course, no chip can contain any bad (marked) squares. It might not be possible to cut the plate so that every good unit square is a part of some memory chip. The corporation wants to waste as little good squares as possible. Therefore they would like to know how to cut the plate to make the maximum number of chips possible.
            Task
            You are given the dimensions of several silicon plates and a list of all bad unit squares for each plate. Your task is to write a program that computes for each plate the maximum number of chips that can be cut out of the plate.

             

            Input
            The first line of the input file consists of a single integer D (1 <= D <= 5), denoting the number of silicon plates. D blocks follow, each describing one silicon plate. The first line of each block contains three integers N (1 <= N <= 150), M (1 <= M <= 10), K (0 <= K <= MN) separated by single spaces. N is the length of the plate, M is its height and K is the number of bad squares in the plate. The following K lines contain a list of bad squares. Each line consists of two integers x and y (1 <= x <= N, 1 <= y <= M) ?coordinates of one bad square (the upper left square has coordinates [1, 1], the bottom right is [N,M]).

            Output
            For each plate in the input file output a single line containing the maximum number of memory chips that can be cut out of the plate.

            Sample Input

            2
            6 6 5
            1 4
            4 6
            2 2
            3 6
            6 4
            6 5 4
            3 3
            6 1
            6 2
            6 4
            

             

            Sample Output

            3
            4

             

            Source
            CEOI 2002

            CODE:

            #include <iostream>
            using namespace std;

            int g[150][10], blk[10];
            int d[4][60000];
            int e[11= {1392781243729218765611968359049};
            int n, m, kn;
            int can1, can2, b[10][60000];
            int *l0, *l1, *l2, *l3, *bit0, *bit1, *bit2;

            void build() {
                
            int i, j, tmp;
                
            for (i=0; i<e[10]; i++{
                    j 
            = 0; tmp = i;
                    
            while (tmp > 0{
                        b[j][i] 
            = tmp % 3;
                        tmp 
            /= 3;
                        j
            ++;
                    }

                }

            }
             

            inline 
            int maxt(int a, int b) {
                
            return a > b ? a : b;
            }


            void solve() {
                
            int i, j, k, x, y, a1, a2, p, c;
                scanf(
            "%d%d%d"&n, &m, &kn);
                memset(g, 
            0sizeof(g));
                memset(d, 
            0sizeof(d));
                
            for (i=0; i<kn; i++{
                    scanf(
            "%d%d"&x, &y);
                    g[x
            -1][y-1= 1;
                }

                
            for (i=0; i<m; i++) blk[i] = 1 - g[0][i];
                
            for (i=1, c=2; i<n; i++{
                    
            for (j=0; j<m; j++{
                        
            if (g[i][j]) blk[j] = 0;
                        
            else blk[j]++;
                        c 
            = (c+1)%4;
                        can1 
            = (j>0 && blk[j]>2 && blk[j-1]>2);
                        can2 
            = (j>1 && blk[j]>1 && blk[j-1]>1 && blk[j-2]>1);
                        a1 
            = 2*e[j]+2*e[j-1];
                        a2 
            = e[j]+e[j-1]+e[j-2];
                        l0 
            = d[c]; l1 = d[(c+3)%4]; l2 = d[(c+2)%4]; l3 = d[(c+1)%4];
                        bit0 
            = b[j]; 
                        
            if (j>0) bit1 = b[j-1]; 
                        
            if (j>1) bit2 = b[j-2];
                        
            for (p=0; p<e[m]; p++{
                            
            if (bit0[p]) {
                                l0[p] 
            = l1[p-e[j]];
                            }
             else {
                                l0[p] 
            = l1[p];
                                
            if (j>0 && !bit1[p]) {
                                    
            if (can1) l0[p] = maxt(l0[p],l2[p+a1]+1);
                                    
            if (can2 && !bit2[p]) l0[p] = maxt(l0[p], l3[p+a2]+1);
                                }

                            }

                        }

                    }

                }

                printf(
            "%d\n", d[c][0]);
            }


            int main() {
                build();
                
            int caseTime;
                scanf(
            "%d"&caseTime);
                
            while (caseTime--{
                    solve();
                }

                
            return 0;
            }


             
            posted on 2007-04-18 11:42 閱讀(1774) 評論(0)  編輯 收藏 引用 所屬分類: ACM題目
            久久久无码一区二区三区| 国产精品伊人久久伊人电影| 一级做a爰片久久毛片毛片| 久久综合久久伊人| 久久久亚洲裙底偷窥综合| 成人妇女免费播放久久久| 欧美成a人片免费看久久| 伊人久久久AV老熟妇色| 99久久精品免费观看国产| 精品人妻伦九区久久AAA片69| 欧美久久精品一级c片片| 久久人人爽人人爽人人片AV高清 | 久久午夜无码鲁丝片午夜精品| 综合久久精品色| 亚洲国产精品久久久久久| 亚洲精品乱码久久久久久| 久久国产精品国语对白| 99久久99久久久精品齐齐| 人妻无码αv中文字幕久久琪琪布| 久久免费精品一区二区| 久久久久人妻一区精品性色av| 久久99精品九九九久久婷婷| 久久天天躁狠狠躁夜夜躁2O2O| 国产精品成人久久久| 久久久精品久久久久久 | 亚洲国产天堂久久久久久| 精品久久久久久亚洲| 久久精品国产亚洲AV无码麻豆| 精品国产日韩久久亚洲| 久久久久香蕉视频| 久久久精品国产亚洲成人满18免费网站| 国产精品久久久久9999高清| 无码人妻少妇久久中文字幕蜜桃 | 一本一本久久aa综合精品| 久久亚洲欧洲国产综合| 国产精自产拍久久久久久蜜 | 2019久久久高清456| 久久久国产视频| 99久久精品免费看国产一区二区三区| 久久天天躁狠狠躁夜夜2020一| 久久天天躁狠狠躁夜夜躁2014|