一些神奇的(优化)板子——来自Loi_black的博客

deque<int>q;
void spfa(int s)
{
    for(int i=1;i<=n;i++)
        d[i]=1e9;
    d[s]=0;
    q.push_back(s);
    used[s]=1;
    while(!q.empty())
    {
        int x=q.front();
        q.pop_front();
        used[x]=0;
        for(int i=first[x];i;i=next[i])
        {
            int u=hh[i].t;
            if(d[u]>d[x]+hh[i].c)
            {
                d[u]=d[x]+hh[i].c;
                if(!used[u])
                {
                    used[u]=1;
                    if(!q.empty())
                    {
                        if(d[u]<d[q.front()])
                            q.push_front(u);
                        else
                            q.push_back(u);
                    }
                    else
                        q.push_back(u);
                }
            }
        }
    }
}   
//spfa+(slf优化)
int tim[maxn];
bool spfa(int s)
{
    d[s]=0;
    q.push(s);
    used[s]=1;
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        used[x]=0;
        for(int i=first[x];i;i=next[i])
        {
            int u=hh[i].t;
            if(d[u]>d[x]+hh[i].c)
            {
                d[u]=d[x]+hh[i].c;
                if(!used[u])
                {
                    if(++tim[u]>n)
                        return false;
                    q.push(u);
                    used[u]=1;
                }
            }
        }
    }
    return true;
}

//spfa判负环
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<queue>
using namespace std;
const int maxn=200005;
struct dqs
{
    int f,t,c;
}hh[maxn];
struct dqm
{
    int num,dis;
};
bool operator <(dqm a,dqm b)
{
    return a.dis>b.dis;
}
int tot=0,first[maxn],next[maxn],d[maxn];
bool used[maxn];
void build(int f,int t,int c)
{
    hh[++tot]=(dqs){f,t,c};
    next[tot]=first[f];
    first[f]=tot;
}
priority_queue<dqm>q;
void dij(int s)
{
    d[s]=0;
    q.push({s,d[s]});
    while(!q.empty())
    {
        int head = q.top().num;
        q.pop();
        used[head]=1;
        for(int i=first[head];i;i=next[i])
        {
            int u=hh[i].t;
            if(d[u]>d[head]+hh[i].c)
            {
                d[u]=d[head]+hh[i].c;
                if(!used[u])
                    q.push((dqm){u,d[u]});
            }
        }
    }
}
int main()
{
    int n,m,s,e;
    scanf("%d%d%d%d",&n,&m,&s,&e);
    ......
}
//dijkstra+ 堆
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
const int maxn=250010;
struct dqs
{
    int f,t,c;
}hh[maxn<<1];
int tot=0,fa[maxn][31],next[maxn],first[maxn],f[maxn],d[maxn];
void build(int ff,int tt,int cc)
{
    hh[++tot]=(dqs){ff,tt,cc};
    next[tot]=first[ff];
    first[ff]=tot;
}
int deep[maxn];
void dfs(int x,int sd)
{
    deep[x]=sd;
    int u;
    for(int i=first[x];i;i=next[i])
    {
        u=hh[i].t;
        if(!deep[u]&&u)
        {
            f[u]=x;
            d[u]=d[x]+hh[i].c;
            dfs(u,sd+1);
        }
    }
}
int lca(int x,int y)
{
    if(deep[x]<deep[y])
    swap(x,y);
    int deepcha=deep[x]-deep[y];
    for(int i=0;i<=30;i++)
    {
        if(1<<i&deepcha)
        x=fa[x][i];
    }
    for(int i=30;i>=0;i--)
    {
        if(fa[x][i]!=fa[y][i])
        {
            x=fa[x][i];
            y=fa[y][i];
        }
    }
    if(x!=y)
        return f[x];
    return x;
}
int main()
{
    int n;
    scanf("%d",&n);
    int u,v,c;
    for(int i=1;i<n;i++)
    {
        scanf("%d%d%d",&u,&v,&c);
        build(u,v,c);
        build(v,u,c);
    }
    dfs(0,0);
    for(int i=0;i<n;i++)
        fa[i][0]=f[i];
    for(int j=1;j<=20;j++)
    for(int i=1;i<=n;i++)
        fa[i][j]=fa[fa[i][j-1]][j-1];
    int m;
    scanf("%d",&m);
    for(int i=1;i<=m;i++)
    {
        scanf("%d%d",&u,&v);
        int xx=lca(u,v);
        printf("%d\n",d[u]+d[v]-2*d[xx]);
    }
    return 0;
}

//倍增lca
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<queue>
using namespace std;
const int maxn=200005;
struct dqs
{
    int f,t,c;
}hh[maxn];
int tot=0,first[maxn],next[maxn],du[maxn];
void build(int f,int t)
{
    hh[++tot]=(dqs){f,t};
    next[tot]=first[f];
    first[f]=tot;
}
queue<int>q;
void tp()
{
    while(!q.empty())
    {
        int x=q.front();
        q.pop();
        printf("%d ",x);
        for(int i=first[x];i;i=next[i])
        {
            int u=hh[i].t;
            du[u]--;
            if(!du[u])
            q.push(u);
        }
    }
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        while(true)
        {
            scanf("%d",&x);
            if(x==0)
            break;
            build(i,x);
            du[x]++;
        }
    }
    for(int i=1;i<=n;i++)
        if(!du[i])
            q.push(i);
    tp();
    return 0;
}
//拓扑排序
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
const int maxn=10005;
struct dqs
{
    int f,t;
}hh[maxn];
int tot=0;
int first[maxn],next[maxn];
void build(int f,int t)
{
    hh[++tot]=(dqs){f,t};
    next[tot]=first[f];
    first[f]=tot;
}
int dfn[maxn],low[maxn],stack[maxn],size[maxn],du[maxn],jlqlt[maxn];
bool in_stack[maxn];
int tot1=0,cnt=0,snum=0;
void group(int x)
{
    dfn[x]=low[x]=++tot1;
    stack[++snum]=x;
    in_stack[x]=1;
    for(int i=first[x];i;i=next[i])
    {
        int u=hh[i].t;
        if(!dfn[u])
        {
            group(u);
            low[x]=min(low[x],low[u]);
        }
        else if(in_stack[u])
            low[x]=min(low[x],dfn[u]);
    }
    if(dfn[x]==low[x])
    {
        cnt++;
        while(true)
        {
            jlqlt[stack[snum]]=cnt;
            in_stack[stack[snum]]=0;
            size[cnt]++;
            snum--;
            if(stack[snum+1]==x)
                break;
        }
    }
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++)
    {
        int a,b;
        scanf("%d%d",&a,&b);
        build(a,b);
    }
    for(int i=1;i<=n;i++)
        if(!dfn[i])
            group(i);
    for(int i=1;i<=n;i++)
        for(int j=first[i];j;j=next[j])
        {
            int u=hh[j].t;
            if(jlqlt[i]!=jlqlt[u])
                du[jlqlt[i]]++;
        }
    int sum1=0,sum2=0,x;
    for(int i=1;i<=cnt;i++)
    {
        if(size[i]>1)
            sum1++;
        if(!du[i])
        {
            sum2++;
            x=i;        
        }
    }
    printf("%d\n",sum1);
    if(sum2==1&&size[x]!=1)
    {
        for(int i=1;i<=n;i++)
        {
            if(jlqlt[i]==x)
            printf("%d ",i);
        }
    }
    else
    printf("-1\n");
    return 0;
} 

//trajan
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
const int maxn=200005; 
long long tmp[maxn],a[maxn];
long long ans=0;
void merge(int l,int mid,int r)
{
    int i=l,j=mid+1,k=l;
    while(i<=mid&&j<=r)
    {
        if(a[i]>a[j])
        {
            tmp[k++]=a[j++];
            ans+=mid+1-i;
        }
        else
            tmp[k++]=a[i++]; 
    }
    while(i<=mid)
        tmp[k++]=a[i++];
    while(j<=r)
        tmp[k++]=a[j++];
    for(int i=l;i<=r;i++)
        a[i]=tmp[i];
}
void merge_sort(int l,int r)
{
    if(l<r)
    {
        int mid=(l+r)>>1;
        merge_sort(l,mid);
        merge_sort(mid+1,r);
        merge(l,mid,r);
    } 
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%lld",&a[i]);
    merge_sort(1,n);
    for(int i=1;i<=n;i++)
        cout<<a[i]<<" ";
    cout<<endl;
    printf("%lld",ans);
}

//归并排序
#include<iostream>
#include<cstdio>
#include<cstdlib>
using namespace std;
const int maxn=200005;
int heap[maxn],cnt=0;
void push(int x)
{
    cnt++;
    int now=cnt;
    heap[now]=x;
    while(now>1)
    {
        if(heap[now]<heap[now/2])
        {
            swap(heap[now],heap[now/2]);
            now/=2;
        }
        else break;
    }
}
void pop()
{
    heap[1]=heap[cnt];
    int now=1;
    while(now*2+1<=cnt)
    {
        int l=now*2,r=now*2+1;
        if(heap[l]<heap[now])
        {
            if(heap[r]<heap[l])
                swap(l,r);
            swap(heap[l],heap[now]);
            now=l;
        }
        else if(heap[r]<heap[now])
        {
            swap(heap[r],heap[now]);
            now=r;
        }
        else break;
    }
    cnt--;
}
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int x;
        scanf("%d",&x);
        push(x);
    }
    for(int i=1;i<=n;i++)
    {
        printf("%d ",heap[1]);
        pop();
    }
}

//手打最小堆(最大堆同理)

 

转载于:https://www.cnblogs.com/ZDHYXZ/p/7636640.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
智慧校园信息化系统解决方案旨在通过先进的信息技术,实现教育的全方位创新和优质资源的普及共享。该方案依据国家和地方政策背景,如教育部《教育信息化“十三五”规划》和《教育信息化十年发展规划》,以信息技术的革命性影响为指导,推进教育信息化建设,实现教育思想和方法的创新。 技术发展为智慧校园建设提供了强有力的支撑。方案涵盖了互连互通、优质资源共享、宽带网络、移动APP、电子书包、电子教学白板、3D打印、VR虚拟教学等技术应用,以及大数据和云计算技术,提升了教学数据记录和分析水平。此外,教育资源公共服务平台、教育管理公共服务平台等平台建设,进一步提高了教学、管控的效率。 智慧校园系统由智慧教学、智慧管控和智慧办公三大部分组成,各自具有丰富的应用场景。智慧教学包括微课、公开课、精品课等教学资源的整合和共享,支持在线编辑、录播资源、教学分析等功能。智慧管控则通过平安校园、可视对讲、紧急求助、视频监控等手段,保障校园安全。智慧办公则利用远程视讯、无纸化会议、数字会议等技术,提高行政效率和会议质量。 教育录播系统作为智慧校园的重要组成部分,提供了一套满足学校和教育局需求的解决方案。它包括标准课室、微格课室、精品课室等,通过自动五机位方案、高保真音频采集、一键式录课等功能,实现了优质教学资源的录制和共享。此外,录播系统还包括互动教学、录播班班通、教育中控、校园广播等应用,促进了教育资源的均衡化发展。 智慧办公的另一重点是无纸化会议和数字会议系统的建设,它们通过高效的文件管理、会议文件保密处理、本地会议的音频传输和摄像跟踪等功能,实现了会议的高效化和集中管控。这些系统不仅提高了会议的效率和质量,还通过一键管控、无线管控等设计,简化了操作流程,使得会议更加便捷和环保。 总之,智慧校园信息化系统解决方案通过整合先进的信息技术和教学资源,不仅提升了教育质量和管理效率,还为实现教育均衡化和资源共享提供了有力支持,推动了教育现代化的进程。
智慧校园信息化系统解决方案旨在通过先进的信息技术,实现教育的全方位创新和优质资源的普及共享。该方案依据国家和地方政策背景,如教育部《教育信息化“十三五”规划》和《教育信息化十年发展规划》,以信息技术的革命性影响为指导,推进教育信息化建设,实现教育思想和方法的创新。 技术发展为智慧校园建设提供了强有力的支撑。方案涵盖了互连互通、优质资源共享、宽带网络、移动APP、电子书包、电子教学白板、3D打印、VR虚拟教学等技术应用,以及大数据和云计算技术,提升了教学数据记录和分析水平。此外,教育资源公共服务平台、教育管理公共服务平台等平台建设,进一步提高了教学、管控的效率。 智慧校园系统由智慧教学、智慧管控和智慧办公三大部分组成,各自具有丰富的应用场景。智慧教学包括微课、公开课、精品课等教学资源的整合和共享,支持在线编辑、录播资源、教学分析等功能。智慧管控则通过平安校园、可视对讲、紧急求助、视频监控等手段,保障校园安全。智慧办公则利用远程视讯、无纸化会议、数字会议等技术,提高行政效率和会议质量。 教育录播系统作为智慧校园的重要组成部分,提供了一套满足学校和教育局需求的解决方案。它包括标准课室、微格课室、精品课室等,通过自动五机位方案、高保真音频采集、一键式录课等功能,实现了优质教学资源的录制和共享。此外,录播系统还包括互动教学、录播班班通、教育中控、校园广播等应用,促进了教育资源的均衡化发展。 智慧办公的另一重点是无纸化会议和数字会议系统的建设,它们通过高效的文件管理、会议文件保密处理、本地会议的音频传输和摄像跟踪等功能,实现了会议的高效化和集中管控。这些系统不仅提高了会议的效率和质量,还通过一键管控、无线管控等设计,简化了操作流程,使得会议更加便捷和环保。 总之,智慧校园信息化系统解决方案通过整合先进的信息技术和教学资源,不仅提升了教育质量和管理效率,还为实现教育均衡化和资源共享提供了有力支持,推动了教育现代化的进程。
帮我地道的翻译:The differential variational inequalities ((DVIs), for short) are useful for the study of models involving both dynamics and constraints in the form of in￾equalities. They arise in many applications: electrical circuits with ideal diodes, Coulomb friction problems for contacting bodies, economical dynamics, dynamic traffic networks. Pang and Stewart [26], [27] established the existence, unique￾ness, and Lipschitz dependence of solutions subject to boundary conditions for (DVIs) in finite dimensional spaces. Han and Pang investigated a class of dif￾ferential quasi-variational inequalities in [11], and Li, Huang and O’Regan [18] studied a class of differential mixed variational inequalities in finite dimensional Well-Posedness of Differential Mixed Quasi-Variational-Inequalities 137 spaces. Gwinner [8] obtained an equivalence result between (DVIs) and projected dynamical systems. In [9] he also proved a stability property for (DVIs) by using the monotonicity method of Browder and Minty, and Mosco set convergence. Chen and Wang [4] studied dynamic Nash equilibrium problems which have the formulation of differential mixed quasi-variational inequalities. Elastoplastic contact problems can also be incorporated into (DMQVIs) formulation because general dynamic processes in the nonsmooth unilateral contact problems are governed by quasi-variational inequalities. A numerical study for nonsmooth contact problems with Tresca friction can be found in [10], Liu, Loi and Obukhovskii [19] studied the existence and global bifurcation for periodic solutions of a class of (DVIs) by using the topological degree theory for multivalued maps and the method of guiding functions. For more details about (DVIs) we refer to [3], [30], [12], [22]–[21].
05-30
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值