TC SRM 591

表示第一次在div1,我要记录一下...

木有挂0,第一题不怎么难的,读题读了20分钟,又想了20分钟,时间有点长,然后各种小心,然后得了140分....

后两个题,根本木有看,貌似做出来的也不多。。。涨了6分。。。这。。。

我的成绩很稳定,一直都是一个题。。。

贴了代码,填充一下内容。。。

第一题:

class TheTree
{
public:
    int maximumDiameter(vector <int> cnt)
    {
        int i,j,n,temp,maxz;
        int p[101];
        n = 0;
        maxz = 0;
        for(it = cnt.begin();it != cnt.end();it ++)
        {
            p[n++] = *it;
        }
        for(i = 0;i < n;i ++)
        {
            temp = n-i;
            for(j = i;j < n;j ++)
            {
                if(p[j] == 0)
                continue;
                if(p[j] == 1)
                break;
            }
            temp += j-i;
            maxz = max(maxz,temp);
        }
        return maxz;
    }
};
原文地址:https://www.cnblogs.com/naix-x/p/3325820.html