前言
依旧想去德育基地…
成绩
RankRankRank | PersonPersonPerson | ScoreScoreScore | AAA | BBB | CCC |
---|---|---|---|---|---|
111 | 2017xxy2017xxy2017xxy | 210210210 | 404040 | 100100100 | 707070 |
222 | 2017myself2017myself2017myself | 190190190 | 202020 | 100100100 | 707070 |
333 | 2017lxf2017lxf2017lxf | 180180180 | 000 | 909090 | 909090 |
444 | 2017zyc2017zyc2017zyc | 170170170 | 000 | 100100100 | 707070 |
555 | 2017zyx2017zyx2017zyx | 150150150 | 404040 | 606060 | 505050 |
666 | 2017xjq2017xjq2017xjq | 130130130 | 000 | 100100100 | 303030 |
777 | 2017lrz2017lrz2017lrz | 100100100 | 101010 | 909090 | 000 |
777 | 2013lyk2013lyk2013lyk | 100100100 | 000 | 100100100 | 000 |
999 | 2015zyf2015zyf2015zyf | 909090 | 202020 | 000 | 707070 |
101010 | 2013lxh2013lxh2013lxh | 909090 | 000 | 909090 | 000 |
正题
T1:nssl1254−A(T1:nssl1254-A(T1:nssl1254−A(林下风气)))【树形dpdpdp】
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/83541098
T2:nssl1255−B(T2:nssl1255-B(T2:nssl1255−B(轻功)))【SPFA,SPFA,SPFA,分层图】
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/83541258
T3:nssl1256−C(T3:nssl1256-C(T3:nssl1256−C(盟主的忧虑)))【并查集】
博客链接:
https://blog.csdn.net/Mr_wuyongcong/article/details/83541476
someofcodesome\ of\ codesome of code
T2 20分code
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 4000
#define XJQ 19260817
using namespace std;
struct node{int to,next;
}a[N];
int ls[N],w[N],maxs,mins,ans,n,k,tot,x,y,in[N];
void addl(int x,int y)
{a[++tot].to=y;a[tot].next=ls[x];ls[x]=tot;
}
void dp1()
{for(int i=1;i<=n;i++){maxs=0;mins=2147483647;for(int j=i;j<=n;j++){maxs=max(maxs,w[j]);mins=min(mins,w[j]);if(maxs-mins==k) ans++;}}printf("%d",ans);
}
int main()
{scanf("%d%d",&n,&k);for(int i=1;i<=n;i++)scanf("%d",&w[i]);for(int i=1;i<n;i++){scanf("%d%d",&x,&y);addl(x,y);addl(y,x);in[x]++;in[y]++;maxs=max(maxs,max(in[x],in[y]));}if(maxs<=2)dp1();else printf("0");
}
T3 70分code
#include<cstdio>
#include<algorithm>
#define N 100010
using namespace std;
struct node{int to,w,next,from;
}a[N];
int ls[N],tot,x,y,w,ans,dep[N],n,m,S,dfn[N],end[N],cnt;
void addl(int x,int y,int w)
{a[++tot].to=y;a[tot].w=w;a[tot].next=ls[x];ls[x]=tot;a[tot].from=x;
}
void dfs(int x,int fa)
{dfn[x]=++cnt;dep[x]=dep[fa]+1;for(int i=ls[x];i;i=a[i].next)if(i<S){int y=a[i].to;if(y==fa) continue;dfs(y,x);}end[x]=cnt;
}
bool cmp(node x,node y)
{return x.from<y.from;}
int next(int x)
{while(dep[a[x].from]>dep[a[x].to]) x++;return x;
}
int main()
{scanf("%d%d",&n,&m);for(int i=1;i<n;i++){scanf("%d%d",&x,&y);addl(x,y,0);addl(y,x,0);}S=tot+1;for(int i=1;i<=m;i++){scanf("%d%d%d",&x,&y,&w);addl(x,y,w);}dfs(1,0);for(int i=1;i<S;i+=2){ans=2147483647;int x=a[i].to;if(dep[a[i].to]<dep[a[i+1].to]) x=a[i+1].to;for(int j=S;j<=tot;j++)if(dfn[a[j].to]>=dfn[x]&&dfn[a[j].to]<=end[x]&&(dfn[a[j].from]<dfn[x]||dfn[a[j].from]>end[x])||dfn[a[j].from]>=dfn[x]&&dfn[a[j].from]<=end[x]&&(dfn[a[j].to]<dfn[x]||dfn[a[j].to]>end[x]))ans=min(ans,a[j].w);if(ans==2147483647) printf("-1\n");else printf("%d\n",ans);}
}
尾声
话说题目又ABC。老师改题面了