摘要:
思路:dp[i]=dp[j]+sum[i]-sum[j]-(i-j)*num[j+1];然后就是比较斜率。注意的时这里j+t#include#include#include#include#define Maxn 400010#define LL __int64using namespace std;LL num[Maxn],sum[Maxn],dp[Maxn];int que[Maxn*10];LL Getleft(int j,int k){ return dp[j]-sum[j]+j*num[j+1]-(dp[k]-sum[k]+k*num[k+1]);}LL Getright(in... 阅读全文
摘要:
思路:将每个关系当成一条有向边,查询时就判断之间存在路径。#include#include#include#include#include#include#define Maxn 210using namespace std;map g;map ver;int head[Maxn*2],vi[Maxn*2],e;struct Edge{ int u,v,next;}edge[Maxn*Maxn*2];void add(int u,int v){ edge[e].u=u,edge[e].v=v,edge[e].next=head[u],head[u]=e++;}bool dfs(in... 阅读全文