【CCF】无线网络 搜索+思维
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<stack>
#include<vector> using namespace std;
typedef long long ll;
const double eps=1e-;
const int maxn=2e2+;
const int maxm=maxn*maxn;
int n,m,k;
ll r;
struct node{
ll x;
ll y;
node(ll _x,ll _y):x(_x),y(_y){}
};
vector<node> g;
bool vis[maxn];
struct Node{
int id;
int step;
int k;
Node(int _id,int _step,int _k):id(_id),step(_step),k(_k){}
};
bool judge(int u,int v){
ll tmp=(g[u].x-g[v].x)*(g[u].x-g[v].x)+(g[u].y-g[v].y)*(g[u].y-g[v].y);
if(tmp<=r*r) return true;
return false;
}
struct edge{
int to;
int nxt;
}e[*maxm];
int tot;
int head[maxn];
void init(){
g.clear();
memset(head,-,sizeof(head));
tot=;
memset(vis,false,sizeof(vis));
}
void add(int u,int v){
e[tot].to=v;
e[tot].nxt=head[u];
head[u]=tot++;
}
int bfs(){
int s=,t=;
queue<Node> Q;
Q.push(Node(s,,));
while(!Q.empty()){
Node q=Q.front();
Q.pop();
if(q.id==t){
return q.step;
}
if(vis[q.id]) continue;
vis[q.id]=true;
int u=q.id;
for(int i=head[u];i!=-;i=e[i].nxt){
int v=e[i].to;
if(v<=n){
Q.push(Node(v,q.step+,q.k));
}else{
if(q.k+<=k){
Q.push(Node(v,q.step+,q.k+));
}
}
} }
return -;
}
int work(){
return bfs()-;
}
int main(){
while(~scanf("%d%d%d%lld",&n,&m,&k,&r)){
init();
ll x,y;
g.push_back(node(,));
for(int i=;i<=n;i++){
scanf("%lld%lld",&x,&y);
g.push_back(node(x,y));
}
for(int i=;i<=m;i++){
scanf("%lld%lld",&x,&y);
g.push_back(node(x,y));
}
for(int i=;i<=n+m;i++){
for(int j=i+;j<=n+m;j++){
if(judge(i,j)){
add(i,j);
add(j,i);
}
}
}
int ans=work();
printf("%d\n",ans);
}
return ;
}
【CCF】无线网络 搜索+思维的更多相关文章
- 【CCF】无线网络 搜索
[思路] 多个起点同时四周扩展广搜,注意会爆int [AC] #include<iostream> #include<cstdio> #include<cstring&g ...
- 破解无线网络密码-BT3如何使用2
本教程只作学习和交流使用,任何其它商用与本人无关, 在开始教程之前, 首先需要用到几个软件,感兴趣的朋友看完贴子后可以去百度搜一下下载地址, 虚拟机: VMware Workstation 6.5 正 ...
- 关于NOIP2014“无线网络发射器选址”一题的衍生题目的思考及思维方向
无线网络发射器选址 题目描述 随着智能手机的日益普及,人们对无线网的需求日益增大.某城市决定对城市内的公共场所覆盖无线网. 假设该城市的布局为由严格平行的129 条东西向街道和129 条南北向街道所形 ...
- CCF CSP 201403-4 无线网络
CCF计算机职业资格认证考试题解系列文章为meelo原创,请务必以链接形式注明本文地址 CCF CSP 201403-4 无线网络 问题描述 目前在一个很大的平面房间里有 n 个无线路由器,每个无线路 ...
- windows XP系统搜索无线网络时提示“windows无法配置此无线连接”,如何处理?
转自:http://support1.lenovo.com.cn/lenovo/wsi/htmls/detail_12839009034375918.html 文章编号:C191612 201 ...
- CCF模拟 无线网络
无线网络 时间限制: 1.0s 内存限制: 256.0MB 问题描述 目前在一个很大的平面房间里有 n 个无线路由器,每个无线路由器都固定在某个点上.任何两个无线路由器只要距离不超过 r 就能互相 ...
- 双系统下(Ubuntu + win7)windows 无法连接无线网络
双系统下(Ubuntu + win7)windows 无法连接无线网络 今天开机登录win7,突然发现无法使用无线网络(WiFi信号标志有个大红叉),于是查看设备驱动,一切正常,这就奇怪了:用Wind ...
- 跑PIN码破解无线网络WIFI密码的原理分析(转)
你们家用的无线路由器安全吗?有人蹭网吗?无线路由器的漏洞在哪里?这么避免蹭网? 想要了解这些,必须要了解加密以及破解原理. 工具/原料 电脑 足够多足够好的wifi信号源 usb无线网卡(非必需) 一 ...
- windows xp 无法连接wpa无线网络
其实以前一直是可以的,不知为什么前几天忽然就不能加入原有的无线网了.我的无线网是WPA加密的,采用DHCP分配IP(但针对特定MAC地址分配静态IP). 在网上找了许久,有的网友认为应该把无线网卡(那 ...
随机推荐
- Python 多线程应用
同步锁 import time import threading def subNum(): global num # print("ok") lock.acquire() # 加 ...
- java基础—面向对象2
一.JAVA类的定义
- C# 数据结构 - 单链表 双链表 环形链表
链表特点(单链表 双链表) 优点:插入和删除非常快.因为单链表只需要修改Next指向的节点,双链表只需要指向Next和Prev的节点就可以完成插入和删除操作. 缺点:当需要查找某一个节点的时候就需要一 ...
- Bootstrap历练实例:默认的进度条
<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...
- 119. Pascal's Triangle II@python
Given a non-negative index k where k ≤ 33, return the kth index row of the Pascal's triangle. Note t ...
- OI算法复习
搜集一些算法,赛前背一背有好处的 转自各大网站 前排感谢:hzwer.风了咕凉 前辈...Orz 快速读入: int read() { ,f=;char ch=getchar(); ;ch=getch ...
- mysql EOF
mysql shell 执行脚本 #!/bin/bash export PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/mysql-5.6/bin:/usr ...
- Ubuntu下kaldi安装
该文章为博主原创,如若转载请注明出处:https://www.cnblogs.com/fengleixue/p/9482202.html 因公司业务需要需使用kaldi语音识别工具,现将kaldi环境 ...
- sql 单表/多表查询去除重复记录
单表distinct 多表group by group by 必须放在 order by 和 limit之前,不然会报错 *************************************** ...
- Solr 中的 docValues=true
前言: 在Lucene4.x之后,出现一个重大的特性,就是索引支持DocValues,这对于广大的solr和elasticsearch用户,无疑来说是一个福音,这玩意的出现通过牺牲一定的磁盘空间带来 ...