南阳理工学院16年个人积分赛第一场总结

  Problen A   FZU  2205 据说题目很水

  这道题就是一道思路题,只需要找到5个点的时候最多有几条路,这道题基本就做出来了.可惜的是自己比赛的时候5个点的最多路径推错了,不是最优答案,于是接下来怎么推都不对.

  当n为偶数是答案应该是:n*n/2/2,也就是(n^2)/4.当n为奇数时:(n^2)/4+(n/2),将多余的点放在中间,就可以多连出(n/2)条边,这个应该才是奇数点时的最优答案.

附上AC代码,公式没化简0.0

#include <cstring>
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <math.h>
#include <set>
#include <time.h>
#pragma comment(linker, "/STACK:102400000,102400000")
const int INF=0x3f3f3f3f;
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        if(n%2)
            printf("%d\n",(n/2)*(n/2)+n/2);
        else printf("%d\n",(n/2)*(n/2));
    }
}




Problen B   FZU  2206 函数求解
一开始看到风神1分钟就A了这道题,以为不需要思考,照着题面一交就行了,于是逗比的写了个双重递归的函数...RE了...然后仔细一想,对于大于20150000的数,会减去n个2015再加上n个2014,其实就是一直减1,减到20150000的时候加上2014,如果这时候不在最上层,又会减去n个2015再加上n个2014...所以对于大于20150000的数,答案就是20152014...想通了之后我自信的样例都不测就交了,结果WA了.当时我还以为是推错了(数学太渣没自信),结果发现我把20152014这个常数用printf()函数以%I64d的格式输出了...改成%d就A了...果然做人不能太自信/(ㄒoㄒ)/~~

AC代码:

#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <set>
using namespace std;
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int n;
        scanf("%d",&n);
        if(n<20150001)
            printf("%d\n",n+2014);
        else
        {
            printf("%d\n",20152014);
        }
    }
    return 0;
}


Problen E   FZU  2209 老S的旅行计划
因为数据很小,所以直接暴力24遍dij 就行了0.0,要注意的是有重边,用邻接表存图比较好吧.还有就是到达点v时的当前时间的控制.当时因为排名很靠后,心态不是很好,有点慌,然后在细节的处理上出现了很多问题,错了7次才A了...对于压力的承受力还是不太行.


AC代码

#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <set>
using namespace std;
const int Maxz=110;
int head[30],Next[20000],edge[30][20000][2],tot;
void Insert(int u,int v,int w,int s)
{
    edge[s][tot][0]=v;
    edge[s][tot][1]=w;
    Next[tot]=head[u];
    head[u]=tot++;
}
struct lt
{
    int u,s;
    int w;
    bool operator < (const lt &cmp)const
    {
        return this->w>cmp.w;
    }
};
int ans[30][Maxz];
bool pd[Maxz];
void priqueue(int u,int s,int z,int n)
{
    memset(pd,0,sizeof(pd));
    ans[z][u]=0;
    priority_queue<lt>q;
    lt a,b;
    a.u=u;
    a.s=s;
    a.w=0;
    q.push(a);
    while(!q.empty())
    {
        a=q.top();
        q.pop();
        if(pd[a.u])
            continue;
        pd[a.u]=true;
        for(int i=0; i<24; ++i)
        {
            int w=(i-a.s+24)%24;
            for(int j=head[a.u]; ~j; j=Next[j])
            {
                int v=edge[i][j][0];
                int f=edge[i][j][1];
                if(ans[z][v]>ans[z][a.u]+f+w)
                {
                    ans[z][v]=ans[z][a.u]+f+w;
                    b.u=v;
                    b.w=ans[z][v];
                    b.s=(a.s+f+w)%24;
                    q.push(b);
                }
            }
        }
    }
}
int main()
{
    int t,cas=0;
    scanf("%d",&t);
    while(t--)
    {
        memset(ans,0x3f,sizeof(ans));
        memset(head,-1,sizeof(head));
        tot=0;
        int n,m,q;
        scanf("%d%d%d",&n,&m,&q);
        for(int i=0; i<m; ++i)
        {
            int u,v,w;
            scanf("%d%d",&u,&v);
            for(int i=0; i<24; ++i)
            {
                scanf("%d",&w);
                Insert(u,v,w,i);
                Insert(v,u,w,i);
            }
        }
        for(int i=0; i<24; ++i)
            priqueue(1,i,i,n);
        printf("Case #%d:",++cas);
        for(int i=0; i<q; ++i)
        {
            int d,s;
            scanf("%d%d",&d,&s);
            if(ans[s][d]<0x3f3f3f3f)
                printf(" %d",ans[s][d]);
            else printf(" -1");
        }
        printf("\n");
    }
    return 0;
}


Problen E   FZU  2210 攻占计划

这道题有毒,如果题意正确的话那就是数据太水了,全部输出1就对了.当时看到题我以为是割点,把tarjan一敲,WA了0.0...然后我就在那想他这题意到底啥意思...难道不是连通图?把入度判断了一下又写了一发tarjan又跪了...想了想...还是没太搞懂题意啊,然后我就死马当活马医,判断下每个节点最多能通向多少个城市,然后把最多的城市编号输出,但是城市的那一边如果没粮仓,这个点就白炸了啊...我自己都不太明白我写的是什么鬼...然后就这么过了...无穷脸蒙逼...


AC代码

#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <set>
using namespace std;
int pos=0;
int head[1010],edge[10100],Next[10100],tot;
void Insert(int u,int v)
{
    edge[tot]=v;
    Next[tot]=head[u];
    head[u]=tot++;
}
bool pd[1010];
int ans[1010];
int dfs(int u)
{
    if(pd[u])
        return ans[u];
    pd[u]=true;
    int temp=0;
    for(int i=head[u]; ~i; i=Next[i])
    {
        int v=edge[i];
        temp+=dfs(v);
    }
    return ans[u]=temp+1;
}
int du[1010];
int main()
{
    int n,m;
    while(~scanf("%d%d",&n,&m))
    {
        memset(pd,0,sizeof(pd));
        memset(head,-1,sizeof(head));
        memset(ans,0,sizeof(ans));
        memset(du,0,sizeof(du));
        tot=0;
        for(int i=0; i<m; ++i)
        {
            int u,v;
            scanf("%d%d",&u,&v);
            Insert(u,v);
            ++du[v];
        }
        int ma=0,a=n+1;
        for(int i=1; i<=n; ++i)
            if(!du[i])
            {
                int temp=dfs(i);
                if(temp>ma)
                {
                    ma=temp;
                    a=i;
                }
            }
        printf("%d\n",a);
    }
    return 0;
}

这场比赛比完我心里想的就是:F题真尼玛坑!然后才是放平心态;别太自信;找规律很重要........

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值