亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb

首頁 > 學院 > 開發設計 > 正文

uvalive 7220

2019-11-10 18:09:46
字體:
來源:轉載
供稿:網友

題目鏈接

Wijaya is a (self-PRoclaimed) hardcore gamer and also a talented programmer. His new game, DungeonTrap (DT), is scheduled to be published by next month. DT is a puzzle-like game and is built for bothiOS and Android platform. In each puzzle, player will be given a grid map ofN rows andM columns.Each cell in the map is either:

? starting point, represented by character ‘A’? goal point, represented by character ‘B’? obstacle, represented by character ‘0’ (zero)? empty cell, represented by character ‘1’ .. ‘9’

The game objective is to prevent an imp (the game’s character) to reach goal point from the startingpoint. From each cell, the imp can move to an adjacent cell (sharing an edge), given the destination cellis not an obstacle. To prevent the imp reaching the goal point, the player can put additional obstacleson empty cells, i.e. by transforming an empty cell into a cell with obstacle. The cost of transforming anempty cell into an obstacle is represented by the empty cell’s character; ‘1’ means the cost is 1 token,‘2’ means 2 tokens, ..., ‘9’ means 9 tokens. The player can continuously transform empty cells, giventhe puzzle is not yet solved. A puzzle is not considered as solved if and only if there exists at least oneway for the imp to reach the goal point (oh, by the way, the imp is not actually moving in the game,it’s supposed to be a puzzle).

Wijaya believes that high is the new low, and it is re ected in this game. The more tokens youspent in each puzzle, the lower your rank is (consequently, the worse player you are). For each puzzle,Wijaya wants to know the worse number of tokens that can be spent by a player.

For example, consider the following2 ×4 map.In this example, the puzzle can be solved by at most 13 tokens. These

are several possible games that might be played by the player:

The darken/underlined cells are those which are transformed.

Note that the previous example plays are not exhaustive, there are other possible plays. The playercannot transform all empty cells into obstacle with 14 tokens without winning the game rst (the bestone can do is 13).

Before the game is published, Wijaya has to do a quality check on the game. He needs to ensureall puzzles are correct and challenging. In particular, he needs your help to determine the maximumnumber of tokens can be spent by a player in each puzzle.

Input

The rst line of input containsT (T≤ 100) denoting the number of cases. Each case begins with twointegers N(2≤ N≤ 100) andM (2≤ M≤ 100) denoting the size of the map (rows and columns,respectively). In the following Nlines, each containsM characters describing the given map. Eachcharacter in the map is either: ‘A’, ‘B’, ‘0’, ‘1’, ‘2’, ..., ‘9’ which meaning has been de ned in the aboveproblem statement. It is guaranteed that ‘A’ and ‘B’ each appear exactly once and never adjacent inthe given map.

Output

For each case, output ‘Case #X:Y ’ (without quotes) in a line whereX is the case number (startsfrom 1) andY is an integer representing the maximum number of tokens can be spent by a player forthe respective case.

Note:

Explanation for 1st sample caseThis is the example from the problem statement

Explanation for 2nd sample caseThere’s no need to transform any empty cell as there’s already no way to reach ‘B’ from ‘A’.

Explanation for 3rd sample caseIn this puzzle, player needs to transforms all empty cells to win the game.

Sample Input

4240A24701B23A0490B223AB53337A496B52

Sample Output

Case #1: 13Case #2: 0Case #3: 8Case #4: 29

題意:給一個n×m的四連通網格圖,A表示起點,B表示終點,0表示障礙,其余數字表示空地,現在要逐個把空地轉化為障礙,當某次轉化后起點和終點不連通時立即結束,最大化所有轉化為障礙的空地的數字之和。

題解:

很明顯可以找一條A->B的路徑,然后將不在這條路徑上的所有其他非障礙點加入答案,然后再選路徑上最大的點加入答案。

我開始是找A->B的最短路,后來發現不一定是這樣。

其實,最終結果就是找一個點,若這個點是最后的那個變成障礙的點,那么答案就是所有非障礙點權值之和-這個點到A,B的權值之和。

所以,我們可以跑兩次最短路,分別求出A和B點到其他點的最短路,然后枚舉每個點,當它為最后一個點時的答案,取最大值就行了。

#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>#include<vector>#include<queue>#include<stack>using namespace std;#define rep(i,a,n) for (int i=a;i<n;i++)#define per(i,a,n) for (int i=n-1;i>=a;i--)#define pb push_back#define fi first#define se secondtypedef vector<int> VI;typedef long long ll;typedef pair<int,int> PII;const int inf=0x3fffffff;const ll mod=1000000007;const int maxn=100+10;char g[maxn][maxn];int d[maxn][maxn],d1[maxn][maxn];int dx[]={1,0,-1,0},dy[]={0,-1,0,1};PII s,e;int n,m;bool ok(int x,int y){    return x>=1&&x<=n&&y>=1&&y<=m&&g[x][y]!='0';}int inq[maxn][maxn];PII q[maxn*maxn];void spfa(){    rep(i,1,n+1) rep(j,1,m+1) d[i][j]=inf;    d[s.first][s.second]=0;    memset(inq,0,sizeof(inq));    inq[s.first][s.second]=1;    int front=0,rear=0;    q[rear++]=s;    while(front!=rear)    {        PII u=q[front++];        if(front>=maxn*maxn) front=0;        inq[u.first][u.second]=0;        int p;        if(g[u.first][u.second]=='A') p=0;        else if(g[u.first][u.second]=='B') p=inf;  //        else p=g[u.first][u.second]-'0';        for(int i=0;i<4;i++)        {            int x=u.first+dx[i],y=u.second+dy[i];            if(ok(x,y))            {                if(d[x][y]>d[u.first][u.second]+p)                {                    d[x][y]=d[u.first][u.second]+p;                    //pre[x][y]=make_pair(u.first,u.second);                    if(inq[x][y]) continue;                    inq[x][y]=1;                    q[rear++]=make_pair(x,y);                    if(rear>=maxn*maxn) rear=0;                }            }        }    }}void spfa1(){    rep(i,1,n+1) rep(j,1,m+1) d1[i][j]=inf;    d1[e.first][e.second]=0;    memset(inq,0,sizeof(inq));    inq[e.first][e.second]=1;    int front=0,rear=0;    q[rear++]=e;    while(front!=rear)    {        PII u=q[front++];        if(front>=maxn*maxn) front=0;        inq[u.first][u.second]=0;        int p;        if(g[u.first][u.second]=='B') p=0;        else if(g[u.first][u.second]=='A') p=inf;  //        else p=g[u.first][u.second]-'0';        for(int i=0;i<4;i++)        {            int x=u.first+dx[i],y=u.second+dy[i];            if(ok(x,y))            {                if(d1[x][y]>d1[u.first][u.second]+p)                {                    d1[x][y]=d1[u.first][u.second]+p;                    //pre[x][y]=make_pair(u.first,u.second);                    if(inq[x][y]) continue;                    inq[x][y]=1;                    q[rear++]=make_pair(x,y);                    if(rear>=maxn*maxn) rear=0;                }            }        }    }}int main(){    int cas;    scanf("%d",&cas);    int kase=0;    while(cas--)    {        scanf("%d%d",&n,&m);        int sum=0;        rep(i,1,n+1)        {            scanf("%s",g[i]+1);            rep(j,1,m+1)            {                if(g[i][j]=='0') continue;                else if(g[i][j]=='A')                {                    s=make_pair(i,j);                }                else if(g[i][j]=='B')                {                    e=make_pair(i,j);                }                else                {                    sum+=g[i][j]-'0';                }            }        }        spfa();        spfa1();        if(d[e.first][e.second]==inf)        {            printf("Case #%d: 0/n",++kase);            continue;        }        int ans=0;        rep(i,1,n+1) rep(j,1,m+1)        {            if(g[i][j]!='A'&&g[i][j]!='B'&&g[i][j]!='0')            {                ans=max(ans,sum-d1[i][j]-d[i][j]);            }        }        printf("Case #%d: %d/n",++kase,ans);    }    return 0;}


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
亚洲香蕉成人av网站在线观看_欧美精品成人91久久久久久久_久久久久久久久久久亚洲_热久久视久久精品18亚洲精品_国产精自产拍久久久久久_亚洲色图国产精品_91精品国产网站_中文字幕欧美日韩精品_国产精品久久久久久亚洲调教_国产精品久久一区_性夜试看影院91社区_97在线观看视频国产_68精品久久久久久欧美_欧美精品在线观看_国产精品一区二区久久精品_欧美老女人bb
久久久国产精品x99av| 夜夜嗨av一区二区三区免费区| 亚洲成人久久久久| 亚洲成人免费在线视频| 久久综合免费视频影院| 一个色综合导航| 97人人爽人人喊人人模波多| 久久久久久久影视| 国产成人涩涩涩视频在线观看| 中文字幕av一区二区| 色一区av在线| 欧美做受高潮电影o| 国产欧美最新羞羞视频在线观看| 国产欧洲精品视频| 欧美性生交大片免费| 亚洲精品wwwww| 欧美大全免费观看电视剧大泉洋| 九九久久综合网站| 日本精品久久久久久久| 亚洲国产精品成人一区二区| 精品视频中文字幕| 91在线视频九色| 国产日本欧美一区| 欧洲永久精品大片ww免费漫画| 一区二区三区在线播放欧美| 欧美激情18p| 91精品国产777在线观看| 热门国产精品亚洲第一区在线| 欧洲成人在线视频| 中文字幕精品av| 欧美国产日韩一区二区在线观看| 中文国产成人精品| 欧美成人精品xxx| 国外日韩电影在线观看| 中文在线不卡视频| 欧美色道久久88综合亚洲精品| 亚洲成人教育av| 日韩在线视频二区| 性色av一区二区三区在线观看| 第一福利永久视频精品| 国产在线视频不卡| 亚洲一区二区三区在线视频| 国产一区二区三区久久精品| 亚洲一区亚洲二区亚洲三区| 精品国偷自产在线视频| 国产亚洲视频在线观看| 国产视频在线观看一区二区| 亚洲成人av资源网| 91成人在线观看国产| 亚洲天堂色网站| 尤物yw午夜国产精品视频明星| 茄子视频成人在线| 日韩在线观看你懂的| 亚洲成色777777在线观看影院| 色系列之999| 久久久久久亚洲| 亚洲性视频网站| 日韩精品极品毛片系列视频| 91九色视频在线| 国产精品美女av| 日韩av在线最新| 久久国产精品影视| 国产中文欧美精品| 欧美成人精品在线播放| 97超视频免费观看| 国产精品国产三级国产aⅴ浪潮| 日韩美女av在线免费观看| 国内揄拍国内精品| 欧美激情a∨在线视频播放| 亚洲欧洲一区二区三区久久| 91精品国产自产91精品| 国产精品一久久香蕉国产线看观看| 国产在线观看不卡| 久久人人看视频| 亚洲人成在线播放| 亚洲精品小视频在线观看| 久久久久久国产免费| 亚洲欧洲在线看| 91探花福利精品国产自产在线| 2019国产精品自在线拍国产不卡| 欧美日韩午夜视频在线观看| 国产一区二区三区在线观看视频| 亚洲无线码在线一区观看| 国产精品视频99| 欧美精品videos另类日本| 国产成人97精品免费看片| 欧美大片网站在线观看| 久久久久在线观看| 国产一区二区三区丝袜| 日韩精品黄色网| 久久久久久久久久av| 国内精品久久久久影院优| 久久精品视频免费播放| 欧美成人精品一区二区| 成人欧美一区二区三区黑人孕妇| 日韩在线欧美在线| 色与欲影视天天看综合网| 亚洲精品中文字幕有码专区| 日韩成人av网| 中文字幕九色91在线| 日韩av综合网| 成人国产在线视频| 成年无码av片在线| 久久精品国产亚洲精品2020| 久久香蕉频线观| 国产91精品最新在线播放| 欧美老少做受xxxx高潮| 美女扒开尿口让男人操亚洲视频网站| 精品成人乱色一区二区| 欧美国产日韩一区| 国产精品吹潮在线观看| 影音先锋欧美精品| 亚洲国产精品yw在线观看| 日韩av免费看| 午夜精品久久久久久99热| 国产成人综合精品| 日韩免费观看av| 日韩美女免费观看| 日韩在线观看免费av| 日韩欧美极品在线观看| 亚洲精品午夜精品| 岛国精品视频在线播放| 国产综合久久久久| 国产成人aa精品一区在线播放| 2019中文字幕全在线观看| 宅男66日本亚洲欧美视频| 欧美在线视频免费| 日韩免费在线播放| 97香蕉久久夜色精品国产| 色噜噜亚洲精品中文字幕| 92看片淫黄大片欧美看国产片| 亚洲第一网中文字幕| 日韩免费看的电影电视剧大全| 久久国产精品首页| 久久99久久久久久久噜噜| 国产精品成人va在线观看| 日韩亚洲欧美中文在线| 亚洲性xxxx| 亚洲精品大尺度| 91久久综合亚洲鲁鲁五月天| 欧美日韩一区二区在线| 九九精品视频在线观看| 久热爱精品视频线路一| 国模叶桐国产精品一区| 久久久亚洲福利精品午夜| 国产精品久久久久7777婷婷| 日韩av综合网站| 亚洲精品国产精品国自产在线| 亚洲国产精品999| 欧美性猛交xxxx免费看漫画| 成人性生交大片免费观看嘿嘿视频| 青草成人免费视频| 色综合影院在线| 81精品国产乱码久久久久久| 欧美精品久久久久久久免费观看| 国产精品av网站| 欧美日韩另类视频| 91在线视频九色| 国产精品亚洲一区二区三区| 精品福利视频导航| 欧美视频在线观看免费| 国产精品热视频| 精品人伦一区二区三区蜜桃网站| 国产精品麻豆va在线播放|