POJ 3592 Instantaneous Transference 缩点构图求最长路

本文深入探讨了游戏开发领域的关键技术,包括游戏引擎、编程语言、硬件优化等,并重点阐述了AI音视频处理的应用场景和实现方法,如语义识别、语音识别、AR增强现实等。通过实例分析,揭示了这些技术如何提升游戏体验和互动性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Instantaneous Transference
Time Limit: 5000MS Memory Limit: 65536K
Total Submissions: 5496 Accepted: 1208

Description

It was long ago when we played the game Red Alert. There is a magic function for the game objects which is called instantaneous transfer. When an object uses this magic function, it will be transferred to the specified point immediately, regardless of how far it is.

Now there is a mining area, and you are driving an ore-miner truck. Your mission is to take the maximum ores in the field.

The ore area is a rectangle region which is composed by n × m small squares, some of the squares have numbers of ores, while some do not. The ores can't be regenerated after taken.

The starting position of the ore-miner truck is the northwest corner of the field. It must move to the eastern or southern adjacent square, while it can not move to the northern or western adjacent square. And some squares have magic power that can instantaneously transfer the truck to a certain square specified. However, as the captain of the ore-miner truck, you can decide whether to use this magic power or to stay still. One magic power square will never lose its magic power; you can use the magic power whenever you get there.

Input

The first line of the input is an integer T which indicates the number of test cases.

For each of the test case, the first will be two integers NM (2 ≤ NM ≤ 40).

The next N lines will describe the map of the mine field. Each of the N lines will be a string that contains M characters. Each character will be an integer X (0 ≤ X ≤ 9) or a '*' or a '#'. The integer X indicates that square hasX units of ores, which your truck could get them all. The '*' indicates this square has a magic power which can transfer truck within an instant. The '#' indicates this square is full of rock and the truck can't move on this square. You can assume that the starting position of the truck will never be a '#' square.

As the map indicates, there are K '*' on the map. Then there follows K lines after the map. The next K lines describe the specified target coordinates for the squares with '*', in the order from north to south then west to east. (the original point is the northwest corner, the coordinate is formatted as north-south, west-east, all from 0 to N - 1,- 1).

Output

For each test case output the maximum units of ores you can take.  

Sample Input

1
2 2
11
1*
0 0

Sample Output

3

Source


在一个n*m的图中,让你从左上角的点走到右下角的点,每个点都有一个数值代表矿石数量,或者*代表瞬间传送到某个点,或者#代表障碍,你只能往右走或者往下走,走到*处,你可以选择往下走或者往右走或者传送到某个点,每走到矿石处,你可以得到此数量矿石,不过一旦得到,此处矿石数量就变为0,问得到的最多矿石数量是多少。
构图:
如果是矿石,则连接它右面的点和下面的点,当然此点不能是#。
如果是*,则连接它右面的点和下面的点和要传送到的点,当然此点也不能是#。
构完图之后,缩点求出缩点之后每个点的权值,然后重新构图。
最后在缩点之后的图上求一遍最长路,即源点到某点获得的最大的矿石。
不要忘了加上源点的矿石数量。
//912K	0MS
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<queue>
#include<algorithm>
#define M 2007
using namespace std;
int n,m,nodes,cnt,scnt,begin;
int head[M],dfn[M],low[M],vis[M],stack[M],belong[M];
char map[M][M];
int val[M],g[M],head1[M],dis[M];
struct E
{
    int v,next,cap;
} edg[M*M],edg1[M*M];
void init()
{
    nodes=scnt=begin=cnt=0;
    memset(head,-1,sizeof(head));
    memset(head1,-1,sizeof(head1));
    memset(dfn,0,sizeof(dfn));
    memset(stack,0,sizeof(stack));
    memset(low,0,sizeof(low));
    memset(vis,0,sizeof(vis));
    memset(val,0,sizeof(val));
}
void addedge(int u,int v)
{
    edg[nodes].v=v;edg[nodes].next=head[u];
    head[u]=nodes++;
}
void addedge1(int u,int v,int w)
{
    edg1[nodes].v=v; edg1[nodes].next=head1[u];
    edg1[nodes].cap=w;
    head1[u]=nodes++;
}
void tarjan(int x)
{
    int v;
    dfn[x]=low[x]=++cnt;
    stack[++begin]=x;
    for(int i=head[x];i!=-1;i=edg[i].next)
    {
        v=edg[i].v;
        if(!dfn[v])
        {
            tarjan(v);
            low[x]=min(low[x],low[v]);
        }
        else if(!vis[v])
            low[x]=min(low[x],dfn[v]);
    }
    if(low[x]==dfn[x])
    {
        scnt++;
        do
        {
            v=stack[begin--];
            belong[v]=scnt;
            val[scnt]+=g[v];
            vis[v]=1;
        }while(v!=x);
    }
}
int spfa(int s)                  
{
    for(int i=0; i<=scnt; i++)dis[i]=-1;
    memset(vis,0,sizeof(vis));
    int count=0;
    queue<int>q;
    q.push(s);
    vis[s] =1;
    dis[s]=0;
    while(!q.empty()) 
    {
        int u =q.front();
        q.pop();
        vis[u]=0;
        for(int i=head1[u]; i!=-1; i=edg1[i].next)
        {
            int v=edg1[i].v;
            if(dis[v]<dis[u]+edg1[i].cap)
            {
                dis[v]=dis[u]+edg1[i].cap;
                if(!vis[v])
                {
                    q.push(v);
                    vis[v]=1;
                }
            }
        }
    }
    int maxx=0;
    for(int i=1; i<=scnt; i++) //求s点到其它点的最大距离
        maxx=max(maxx,dis[i]);
    return maxx+val[s];//返回最大距离+源点本身权值
}
int main()
{
    int t;
    scanf("%d",&t);
    while(t--)
    {
        int xx,yy;
        init();
        scanf("%d%d",&n,&m);
        for(int i=0; i<n; i++)
                scanf("%s",map[i]);
        for(int i=0; i<n; i++)
            for(int j=0; j<m; j++)
                if(map[i][j]=='*')
                {
                    scanf("%d%d",&xx,&yy);
                    int a=i*m+j;
                    int b=xx*m+yy;
                    if(map[xx][yy]!='#')addedge(a,b);//连接*到其转到的点
                    if(i+1<n&&map[i+1][j]!='#')addedge(a,a+m);//连接它的下一行的点
                    if(j+1<m&&map[i][j+1]!='#')addedge(a,a+1);//连接它的下一个点
                    g[a]=0;
                }
                else if(map[i][j]!='#')
                {
                    int a=i*m+j;
                    if(i+1<n&&map[i+1][j]!='#'){ addedge(a,a+m);}//连接它的下一行的点
                    if(j+1<m&&map[i][j+1]!='#'){addedge(a,a+1); }//连接它的下一个点
                    g[a]=map[i][j]-'0';
                }
                else g[i*m+j]=0;
        for(int i=0; i<n*m; i++)
            if(!dfn[i])tarjan(i);
        nodes=0;
        for(int u=0; u<n*m; u++)//重新构图
            for(int j=head[u]; j!=-1; j=edg[j].next)
            {
                int v=edg[j].v;
                if(u!=v&&belong[u]!=belong[v])
                    addedge1(belong[u],belong[v],val[belong[v]]);
            }
        int ans=spfa(belong[0]);//求最长路
        printf("%d\n",ans);
    }
    return 0;
}


内容概要:本文详细介绍了扫描单分子定位显微镜(scanSMLM)技术及其在三维超分辨体积成像中的应用。scanSMLM通过电调透镜(ETL)实现快速轴向扫描,结合4f检测系统将不同焦平面的荧光信号聚焦到固定成像面,从而实现快速、大视场的三维超分辨成像。文章不仅涵盖了系统硬件的设计与实现,还提供了详细的软件代码实现,包括ETL控制、3D样本模拟、体积扫描、单分子定位、3D重建和分子聚类分析等功能。此外,文章还比较了循环扫描与常规扫描模式,展示了前者在光漂白效应上的优势,并通过荧光珠校准、肌动蛋白丝、线粒体网络和流感A病毒血凝素(HA)蛋白聚类的三维成像实验,验证了系统的性能和应用潜力。最后,文章深入探讨了HA蛋白聚类与病毒感染的关系,模拟了24小时内HA聚类的动态变化,提供了从分子到细胞尺度的多尺度分析能力。 适合人群:具备生物学、物理学或工程学背景,对超分辨显微成像技术感兴趣的科研人员,尤其是从事细胞生物学、病毒学或光学成像研究的科学家和技术人员。 使用场景及目标:①理解和掌握scanSMLM技术的工作原理及其在三维超分辨成像中的应用;②学习如何通过Python代码实现完整的scanSMLM系统,包括硬件控制、图像采集、3D重建和数据分析;③应用于单分子水平研究细胞内结构和动态过程,如病毒入侵机制、蛋白质聚类等。 其他说明:本文提供的代码不仅实现了scanSMLM系统的完整工作流程,还涵盖了多种超分辨成像技术的模拟和比较,如STED、GSDIM等。此外,文章还强调了系统在硬件改动小、成像速度快等方面的优势,为研究人员提供了从理论到实践的全面指导。
内容概要:本文详细介绍了基于Seggiani提出的渣层计算模型,针对Prenflo气流床气化炉中炉渣的积累和流动进行了模拟。模型不仅集成了三维代码以提供气化炉内部的温度和浓度分布,还探讨了操作条件变化对炉渣行为的影响。文章通过Python代码实现了模型的核心功能,包括炉渣粘度模型、流动速率计算、厚度更新、与三维模型的集成以及可视化展示。此外,还扩展了模型以考虑炉渣组成对特性的影响,并引入了Bingham流体模型,更精确地描述了含未溶解颗粒的熔渣流动。最后,通过实例展示了氧气-蒸汽流量增加2%时的动态响应,分析了温度、流动特性和渣层分布的变化。 适合人群:从事煤气化技术研究的专业人士、化工过程模拟工程师、以及对工业气化炉操作优化感兴趣的科研人员。 使用场景及目标:①评估不同操作条件下气化炉内炉渣的行为变化;②预测并优化气化炉的操作参数(如温度、氧煤比等),以防止炉渣堵塞;③为工业气化炉的设计和操作提供理论支持和技术指导。 其他说明:该模型的实现基于理论公式和经验数据,为确保模型准确性,实际应用中需要根据具体气化炉的数据进行参数校准。模型还考虑了多个物理场的耦合,包括质量、动量和能量守恒方程,能够模拟不同操作条件下的渣层演变。此外,提供了稳态解器和动态模拟工具,可用于扰动测试和工业应用案例分析。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值