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 ...
随机推荐
- hdu1276(士兵队列训练问题) java集合水过
点击打开链接 有人说这题属于栈或者队列,个人认为说集合应该比較准确点. Problem Description 某部队进行新兵队列训练,将新兵从一開始按顺序依次编号.并排成一行横队,训练的规则例如以下 ...
- bzoj1022: [SHOI2008]小约翰的游戏John(博弈SG-nim游戏)
1022: [SHOI2008]小约翰的游戏John 题目:传送门 题目大意: 一道反nim游戏,即给出n堆石子,每次可以取完任意一堆或一堆中的若干个(至少取1),最后一个取的LOSE 题解: 一道 ...
- ThinkPHP5.0框架开发--第10章 TP5.0验证器
ThinkPHP5.0框架开发--第10章 TP5.0验证器 第10章 TP5.0验证器 ======================================= 今日学习 1.验证器 1) 控 ...
- nyoj--914--Yougth的最大化(二分查找)
Yougth的最大化 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 Yougth现在有n个物品的重量和价值分别是Wi和Vi,你能帮他从中选出k个物品使得单位重量的价值最 ...
- 带你玩转Visual Studio——带你理解多字节编码与Unicode码
目录(?)[-] 多字节字符与宽字节字符 char与wchar_t string与wstring string 与 wstring的相关转换 字符集Charcater Set与字符编码Encoding ...
- C# 实现ADSL自动断网和拨号(适用于拨号用户)
using System;using System.Runtime.InteropServices; public struct RASCONN{ public int dwSize; p ...
- Nginx 禁止 ip 访问
server { listen 80 default_server; server_name _; access_log /logs/ip-access.log main; error_log /lo ...
- Iterator(迭代器) 和generator
数组是可迭代的 var a = []; console.dir(a); 发现这里有一个Symbol.iterator ,说明它是可迭代的. object 是不可以迭代的 var a = {} cons ...
- python做的 QQ未读消息图像
#!/usr/bin/pythonfrom PIL import Image ,ImageDraw, ImageFont#打开所在的文件im=Image.open('test.jpg')#获取图片对象 ...
- Linux Kernel 5.1 RC5发布
我们距离正式的Linux 5.1内核发布还有不到一个月的时间,而今天Linus Torvalds宣布推出预期的Linux Kernel 5.1 RC5版本.Linus Torvalds专门评论了Lin ...