PUBG
题目描述
输入描述:
题目包含多组测试,请处理到文件结束;
第一行是一个整数n,代表地图的大小;
接下来的n行中,每行包含n个整数a,每个数字a代表当前位置敌人的数量;
1 < n <= 100,1 <= a <= 100,-1代表当前位置,-2代表安全区。
输出描述:
对于每组测试数据,请输出从当前位置到安全区所遇到最少的敌人数量,每个输出占一行。
输入
5
6 6 0 -2 3
4 2 1 2 1
2 2 8 9 7
8 1 2 1 -1
9 7 2 1 2
输出
9
输入
5
62 33 18 -2 85
85 73 69 59 83
44 38 84 96 55
-1 11 90 34 50
19 73 45 53 95
输出
173
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#pragma comment(linker, "/stck:1024000000,1024000000")
#define lowbit(x) (x&(-x))
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.1415926535897932384626433832
#define ios() ios::sync_with_stdio(true)
#define INF 0x3f3f3f3f
#define mem(a) ((a,0,sizeof(a)))
typedef long long ll;
int dir[][]={{,},{-,},{,},{,-}};
int dp[][],vis[][];
int g[][];
int n,sx,sy,tx,ty;
struct node
{
int x;
int y;
int value;
bool operator<(const node &a) const
{
return a.value<value;
}
}ans,pos;
void dfs(int u,int v,int A,int B)
{
priority_queue<node>q;
memset(dp,,sizeof(dp));
memset(g,,sizeof(g));
ans.x=u;
ans.y=v;
ans.value=;
dp[u][v]=;
g[u][v]=;
q.push(ans);
while(!q.empty())
{
pos=q.top();
q.pop();
if(pos.x==A && pos.y==B)
{
printf("%d\n",pos.value);
return ;
}
for(int i=;i<;i++)
{
int xx=pos.x+dir[i][];
int yy=pos.y+dir[i][];
if(xx>= && xx<=n && yy>= && yy<=n && dp[xx][yy]>pos.value+vis[xx][yy] && !g[xx][yy])
{
g[xx][yy]=;
ans.x=xx;
ans.y=yy;
ans.value=pos.value+vis[xx][yy];
dp[xx][yy]=pos.value+vis[xx][yy];
q.push(ans);
}
}
}
}
int main()
{
while(scanf("%d",&n)!=EOF)
{
memset(vis,,sizeof(vis));
memset(dp,,sizeof(dp));
for(int i=;i<=n;i++)
{
for(int j=;j<=n;j++)
{
scanf("%d",&vis[i][j]);
if(vis[i][j]==-) {sx=i;sy=j;}
if(vis[i][j]==-) {tx=i;ty=j;}
}
}
vis[tx][ty]=vis[sx][sy]=;
dfs(sx,sy,tx,ty);
}
return ;
}
PUBG的更多相关文章
- 阿里云kubernetes遭入侵pubg进程占用cpu资源100%解决方法
发现服务器CPU占用100%,通过top命令发现pubg -c config.json -t 2占用CPU资源,kill进程会自动启动.黑客入侵方式是kubernetes创建pod. Name: ku ...
- PUBG 1V3 线段树扫描线
PUBG 1V3 这个题目我觉得好难写啊. 感觉自己码力不太行啊. 题目大意是,给你n个人,n个人组成m个队伍,每个队伍最多4个人. 然后给你每一个人的位置队伍信息还有攻击范围. 问当一个队伍剩下一个 ...
- 牛客 PUBG
题目链接:点击打开链接 题目大意:跑毒,跑到安全区,每个地方有敌人,输出路线经过的最少敌人的数量:-1是起点. -2是安全区 输入 5 6 6 0 -2 3 4 2 1 2 1 2 2 8 9 7 8 ...
- “战术竞技类”外挂打击已开始!揭秘腾讯We Test游戏安全服务新动作!
商业转载请联系腾讯WeTest获得授权,非商业转载请注明出处. 原文链接:http://wetest.qq.com/lab/view/353.html We Test导读 国服PUBG的游戏安全将由我 ...
- 网络编程第六讲Select模型
网络模型第六讲Select模型 一丶Select模型是什么 以前我们讲过一个迭代模型.就是只服务一个客户端连接.但是实际网络编程中.复杂的很多. 比如一个 C/S架构程序 (客户端/服务端) 客户端很 ...
- Python 多线程和线程池
一,前言 进程:是程序,资源集合,进程控制块组成,是最小的资源单位 特点:就对Python而言,可以实现真正的并行效果 缺点:进程切换很容易消耗cpu资源,进程之间的通信相对线程来说比较麻烦 线程:是 ...
- Self-Introduce
My name is Leo.I like listening music, especially English song.What's more, I enjoy playing games, l ...
- 2018年北京信息科技大学第十届程序设计竞赛暨ACM选拔赛题解
链接:https://www.nowcoder.com/acm/contest/118/A 来源:牛客网 PUBG 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32768K,其他语 ...
- 阿里云ECS安装Kubernetes问题收集与解答
问题1 kubernetes pod启动报错open /etc/docker/certs.d/registry.access.redhat.com/redhat-ca.crt: no such fil ...
随机推荐
- mount ntfs 失败解决办法
在双系统中,ntfs可能会应为windows的缓存而挂载失败.可用下面命令修复. Use ntfsfix in the terminal, even if you can't access Windo ...
- hbase的命令
1.1. 命令 名称 命令表达式 创建表 create '表名', '列族名1','列族名2','列族名N' 查看所有表 list 描述表 describe ‘表名’ 判断表存在 exists ' ...
- bower 代理
bower 设置: 修改 .bowerrc 文件(如无则新增): { "proxy": "http://proxy.mysite.com:8080", &quo ...
- NetworkX-画图
参考:https://blog.csdn.net/qq951127336/article/details/54586869 1.创建图 networkx有四种图 Graph .DiGraph.Mult ...
- Linxu基本指令
一.Linux权限的概念 Linux下有两种用户:普通用户和超级用户(). 普通用户:在linux下做有限的事情: 超级用户:可以在linux系统下做任何事情,不受限制. 普通用户的提示符是“$”,超 ...
- CF666E Forensic Examination(后缀自动机+线段树合并)
给你一个串S以及一个字符串数组T[1..m],q次询问,每次问S的子串S[pl..pr]在T[l..r]中的哪个串里的出现次数最多,并输出出现次数. 如有多解输出最靠前的那一个. 我们首先对m个字符串 ...
- Python 中多线程之 _thread
_thread模块是python 中多线程操作的一种模块方式,主要的原理是派生出多线程,然后给线程加锁,当线程结束的 时候取消锁,然后执行主程序 thread 模块和锁对象的说明 start_new_ ...
- django xadmin插件 的基本用法 1
1 安装或导入 xadmin 1 pip 安装 2 源码导入 在新建项目中新建extra_apps文件夹并将下载后的源码解压放入 (推荐,方便后续我们可以在源码中自定义一些插件的使用) 注: 具体可 ...
- MAVEN flex
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/20 ...
- readb(), readw(), readl(),writeb(), writew(), writel() 宏函数
参见: http://blog.csdn.net/hustyangju/article/details/20448339