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

            hdu3666

            THE MATRIX PROBLEM

            Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
            Total Submission(s): 3993    Accepted Submission(s): 1022


            Problem Description
            You have been given a matrix CN*M, each element E of CN*M is positive and no more than 1000, The problem is that if there exist N numbers a1, a2, … an and M numbers b1, b2, …, bm, which satisfies that each elements in row-i multiplied with ai and each elements in column-j divided by bj, after this operation every element in this matrix is between L and U, L indicates the lowerbound and U indicates the upperbound of these elements.
             

            Input
            There are several test cases. You should process to the end of file.
            Each case includes two parts, in part 1, there are four integers in one line, N,M,L,U, indicating the matrix has N rows and M columns, L is the lowerbound and U is the upperbound (1<=N、M<=400,1<=L<=U<=10000). In part 2, there are N lines, each line includes M integers, and they are the elements of the matrix.
             

            Output
            If there is a solution print "YES", else print "NO".
             

            Sample Input
            3 3 1 6 2 3 4 8 2 6 5 2 9
             

            Sample Output
            YES
             

            Source
            2010 Asia Regional Harbin
             

            額,查分約束系統(tǒng)
            真心wa到爆,一直數(shù)組越界,最后發(fā)現(xiàn)邊數(shù)開少了

            用的spfa
            判斷 1 如果存在某頂點(diǎn)入隊(duì)次數(shù)超過sqrt(n),說明存在負(fù)權(quán)回路,
                   2 如果總?cè)腙?duì)次數(shù)超過2*nn的話,存在負(fù)權(quán)回路,
            不過第二種方法 速度比 第一種快多了
            #include<math.h>
            #include
            <stdio.h>
            #include
            <string.h>
            #define maxm 330000
            #define maxn 1000
            int n,m;
            double l,u,ll,uu;
            int q[1200000];
            int head,tail;
            struct node
            {
                
            int v,next;
                
            double w;
            } edge[maxm];
            int p[maxn];
            int e;
            int nn;
            int sec[maxn];
            void add(int u,int v,double w)
            {
                edge[e].v
            =v;
                edge[e].next
            =p[u];
                edge[e].w
            =w;
                p[u]
            =e++;
            }
            bool spfa()
            {
                
            int i,j,now;
                
            int nnn;
                
            bool flag[maxn];
                
            double dist[maxn];
                nnn
            =(int)(sqrt((double)(nn)));
                memset(dist,
            0,sizeof(dist));
                memset(sec,
            0,sizeof(sec));
                memset(flag,
            0,sizeof(flag));
                head
            =0;
                tail
            =0;
                
            for(i=1; i<=n; i++)
                {
                    tail
            =tail%1200000+1;
                    q[tail]
            =i;
                    flag[i]
            =true;
                    sec[i]
            =1;
                }
                
            while (head!=tail)
                {
                    head
            =head%1200000+1;
                    now
            =q[head];
                    
            if (sec[now]>nnn)
                    {
                        
            return false;
                    }
                    
            for(i=p[now]; i!=-1; i=edge[i].next)
                    {
                        
            if (dist[edge[i].v]>dist[now]+edge[i].w)
                        {
                            dist[edge[i].v]
            =dist[now]+edge[i].w;
                            
            if (!flag[edge[i].v])
                            {
                                sec[edge[i].v]
            ++;
                                flag[edge[i].v]
            =true;
                                tail
            =tail%1200000+1;
                                q[tail]
            =edge[i].v;
                            }
                        }
                    }
                    flag[now]
            =false;
                }
                
            return true;
            }
            int main()
            {
                
            int i,j;
                
            double x;
                
            while (scanf("%d %d %lf %lf",&n,&m,&l,&u)!=EOF)
                {
                    e
            =0;
                    ll
            =log(l);
                    uu
            =log(u);
                    memset(p,
            -1,sizeof(p));
                    
            for(i=1; i<=n; i++)
                    {
                        
            for(j=1; j<=m; j++)
                        {
                            scanf(
            "%lf",&x);
                            x
            =log(x);
                            add(j
            +n,i,uu-x);
                            add(i,j
            +n,x-ll);
                        }
                    }
                    nn
            =n+m;
                    
            if (spfa())
                    {
                        printf(
            "YES\n");
                    }
                    
            else printf("NO\n");
                }
                
            return 0;
            }

            posted on 2012-04-04 19:10 jh818012 閱讀(211) 評論(0)  編輯 收藏 引用

            <2025年7月>
            293012345
            6789101112
            13141516171819
            20212223242526
            272829303112
            3456789

            導(dǎo)航

            統(tǒng)計(jì)

            常用鏈接

            留言簿

            文章檔案(85)

            搜索

            最新評論

            • 1.?re: poj1426
            • 我嚓,,輝哥,,居然搜到你的題解了
            • --season
            • 2.?re: poj3083
            • @王私江
              (8+i)&3 相當(dāng)于是 取余3的意思 因?yàn)?3 的 二進(jìn)制是 000011 和(8+i)
            • --游客
            • 3.?re: poj3414[未登錄]
            • @王私江
              0ms
            • --jh818012
            • 4.?re: poj3414
            • 200+行,跑了多少ms呢?我的130+行哦,你菜啦,哈哈。
            • --王私江
            • 5.?re: poj1426
            • 評論內(nèi)容較長,點(diǎn)擊標(biāo)題查看
            • --王私江
            精品国产VA久久久久久久冰| 国产成人精品综合久久久| 亚洲狠狠婷婷综合久久蜜芽 | 99久久精品国产毛片| 狠狠色丁香婷婷综合久久来来去| 久久无码高潮喷水| 97精品国产91久久久久久| 亚洲日韩欧美一区久久久久我| 国内精品久久久人妻中文字幕| 久久久久这里只有精品| 久久精品国产亚洲AV嫖农村妇女| 久久一区二区免费播放| 久久99精品久久久久久hb无码| 久久精品国产精品亚洲艾草网美妙| 无遮挡粉嫩小泬久久久久久久| 亚洲精品NV久久久久久久久久 | 精品久久人人爽天天玩人人妻| 久久免费的精品国产V∧| 亚洲综合久久夜AV | 国产激情久久久久影院老熟女免费 | 亚洲伊人久久精品影院| 午夜精品久久久内射近拍高清| 91久久精品国产成人久久| 丁香五月网久久综合| 久久人人爽人人爽人人片AV不| 久久婷婷五月综合97色直播| 亚洲午夜福利精品久久| 四虎影视久久久免费观看| 久久精品亚洲福利| 国产福利电影一区二区三区久久老子无码午夜伦不 | 久久久久亚洲精品男人的天堂| 久久精品草草草| 99精品国产在热久久无毒不卡| 麻豆亚洲AV永久无码精品久久 | 国产精品美女久久久m| 久久久久人妻一区二区三区vr| 色欲久久久天天天综合网精品| 97精品伊人久久久大香线蕉| 久久九九兔免费精品6| 久久无码人妻一区二区三区| A狠狠久久蜜臀婷色中文网|