2009ACM多校联合暑期集训(7)——福州大学专场

http://acm.hdu.edu.cn/showproblem.php?pid=2863

http://acm.hdu.edu.cn/forum/read.php?tid=14108

 

2863  Top Shooter——ac.

  其实这题有用贪心的思想吧,但主要还是理清思路,然后把思路完整的模拟出来,但这提代码中有个想法还是很好的。如下:

 while(fall!=m)
        {

            for
(i=0;i<n;i++)
                mi[i]=700;

            for
(;air[k].a==t;k++)

               fly[f++]=k;

           
            for
(i=0;i<n;i
++)
            {

                for
(j=0;j<f;j++)
                    if
(air[fly[j]].h>=view[i]&&air[fly[j]].h<mi[i])
                            mi[i]=air[fly[j]].h;

                if
(mi[i]!=700)
                {

                    for
(j=0;j<f&&air[fly[j]].h!=mi[i];j++);
                    air[fly[j]].h=-1;
                    fly[j]=fly[f-1];//这步是将被打掉的fly[j]所记录的数组下标删除掉,这步直接把最后一个储存的下标赋给要删除的那个,这是很好的想法,仅仅标记的话下次还要判断是否已处理过,很费时间。
                    f--;
                    fall
++;
                }
            }

2864  “Base B”——ac.

   恩 简单题,看懂题意即可。

 

2866 Special Prime——队友ac.

  这题虽主要不是我做的,但也花了很多时间。

 

2869 Paper Cutting Game——ac.

   博弈题,但其本质是招素因子数。

 

2870 Largest Submatrix——赛后ac.

  这题在比赛时我有些,用的是动态规划,但想法太复杂了 ,敲完后觉得会超就先交了下,结果果然超啊,还好先交了一次,后来马上转移阵地了。比赛后要了代码,看了觉得其思想很好啊,用位运算的,贴下代码吧。

关于求相同元素的最大子矩阵。

#include <stdio.h>
#define Max(a,b) ((a)>(b))?(a):(b)
#define N 1002
int
a[N][N],b[N];
char
c[N][N];
int
main()
{

    int
n,m,i,j,k,ma,answer,ans,count,temp;
    while
(scanf("%d%d",&n,&m)!=EOF)
    {

        ans=0;
        for
(i=0;i<n;i++)
            scanf("%s",c[i]);
        for
(i=0;i<n;i++){
            for
(j=0;j<m;j++){
                if
(c[i][j]=='a'||c[i][j]=='w'||c[i][j]=='y'||c[i][j]=='z')
                    a[i][j]=1;
                else

                    a[i][j]=0;
            }
        }

        for
(answer=i=0;i<n;i++)
        {

            for
(k=0;k<m;k++)
                b[k]=1;
            for
(j=i;j<n;j++)
            {

                for
(k=0;k<m;k++)
                    b[k]&=a[j][k];
                for
(k=count=ma=0;k<m;k++)
                {

                    if
(b[k])
                    {

                        count++;
                        if
(ma<count)
                            ma=count;
                    }

                    else
count=0;
                }

                if
(!ma)break;
                temp=(j-i+1)*ma;
                if
(answer<temp)
                    answer=temp;
            }
        }

        ans=Max(ans,answer);//看到这里即可,下面是本题的题目要求的重复该段而已
        for
(i=0;i<n;i++){
            for
(j=0;j<m;j++){
                if
(c[i][j]=='b'||c[i][j]=='w'||c[i][j]=='x'||c[i][j]=='z')
                    a[i][j]=1;
                else

                    a[i][j]=0;
            }
        }

        for
(answer=i=0;i<n;i++)
        {

            for
(k=0;k<m;k++)
                b[k]=1;
            for
(j=i;j<n;j++)
            {

                for
(k=0;k<m;k++)
                    b[k]&=a[j][k];
                for
(k=count=ma=0;k<m;k++)
                {

                    if
(b[k])
                    {

                        count++;
                        if
(ma<count)
                            ma=count;
                    }

                    else
count=0;
                }

                if
(!ma)break;
                temp=(j-i+1)*ma;
                if
(answer<temp)
                    answer=temp;
            }
        }

        ans=Max(ans,answer);
        for
(i=0;i<n;i++){
            for
(j=0;j<m;j++){
                if
(c[i][j]=='c'||c[i][j]=='x'||c[i][j]=='y'||c[i][j]=='z')
                    a[i][j]=1;
                else

                    a[i][j]=0;
            }
        }

        for
(answer=i=0;i<n;i++)
        {

            for
(k=0;k<m;k++)
                b[k]=1;
            for
(j=i;j<n;j++)
            {

                for
(k=0;k<m;k++)
                    b[k]&=a[j][k];
                for
(k=count=ma=0;k<m;k++)
                {

                    if
(b[k])
                    {

                        count++;
                        if
(ma<count)
                            ma=count;
                    }

                    else
count=0;
                }

                if
(!ma)break;
                temp=(j-i+1)*ma;
                if
(answer<temp)
                    answer=temp;
            }
        }

        ans=Max(ans,answer);
        printf("%d/n",ans);
    }

    return
0;
}

 

你可能感兴趣的:(c,ini,AIR)