A - Wireless Network POJ - 2236

题目大意:

         地震啦,电脑的通信坏了,但是正在修理 —— 输入 “ O 1”,表示1号电脑被修好了 ,输入“ S 1 2 ” 表示询问这两台电脑能不能通讯。规定两台电脑之间的距离小于等于d的时候才能通讯,如果A,B能通讯,B能跟C通讯,那么A也能跟C通讯。第一行输入N, d,N表示有几台电脑,d表示最长距离。接下来N行,第i行表示第i台电脑的坐标。接下来输入操作。询问的时候输出“SUCCESS”或者“FAIL”。(输入行数不超过三万行)

参考思路:

     自己的: 输入一个修理成功的电脑,把他存起来,和前面那些已经修好的电脑判断一下,判断条件是:1、已经修好的;2、距离小的。连接过了之后碰到询问的时候,就看看这两个点的根结点是不是一样。

参考代码:

#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <set>

#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
using namespace std;

const int INF=0x3f3f3f3f;
const int SIZE=1e3+10;

struct node{
    int id;
    int fix;  ///是否被修好?
    double x,y;
}cmt[SIZE] ;

int sz[SIZE];
int n;
double d;
///要把电脑连接起来。

double dis(int p,int q)
{
    double temp=(cmt[p].x-cmt[q].x)*(cmt[p].x-cmt[q].x)+(cmt[p].y-cmt[q].y)*(cmt[p].y-cmt[q].y); ///距离

    return temp;
}
int find(int x)
{
    while(cmt[x].id!=x)
    {
        cmt[x].id=cmt[cmt[x].id].id;
        x=cmt[x].id;
    }
    return x;      ///寻找根节点
}
bool connect(int p,int q)
{
    return find(p)==find(q);
}

void un(int p,int q)
{

    if(cmt[q].fix==0||dis(p,q)>d*d) return;  ///没修过?距离太大?
    int pr=find(p);
    int qr=find(q);

    if(pr==qr) return ;  ///根节点已经相同
    if(sz[pr]<sz[qr]) {sz[qr]+=sz[pr];cmt[pr].id=qr;}
    else {sz[pr]+=sz[qr];cmt[qr].id=pr;}//cout<<"UN:"<<cmt[]<<" "<<sz[q]<<endl;
}

void clear()
{
    for(int i=1;i<=n;i++)
        sz[i]=1;
}

int main()
{
    int i,j;
    cin>>n>>d;
    clear();
    for(i=1;i<=n;i++)
    {
        cin>>cmt[i].x>>cmt[i].y;
        cmt[i].fix=0;
        cmt[i].id=i;
    }
    char x;
    int temp,a,b;
    while(cin>>x)
    {
        if(x=='O')
        {
            cin>>temp;
            cmt[temp].fix=1;  ///修过啦
            for(i=1;i<=n;i++)
                if(i!=temp)
                   un(temp,i);
        }
        else
        {
            cin>>a>>b;
            if(!connect(a,b)) cout<<"FAIL\n";
            else cout<<"SUCCESS\n";
        }
    }
    return 0;
}

///http://blog.csdn.net/dm_vincent/article/details/7655764  (并查集相关)

  

     

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Designing a Wireless network<br><br>Foreword xxv<br><br>From Past to Present 1<br><br>Introduction 2<br><br>Exploring Past Discoveries That Led to Wireless 4<br>Discovering Electromagnetism 4<br><br>Exploring Conduction 6<br><br>Inventing the Radio 6<br><br>Mounting Radio-Telephones in Cars 8<br><br>Inventing Computers and Networks 9<br><br>Inventing Cell Phones 11<br><br>Exploring Present Applications for Wireless 12<br>Vertical Markets 13<br>Using Wireless in Delivery Services 14<br>Using Wireless for Public Safety 14<br>Using Wireless in the Financial World 15<br>Using Wireless in the Retail World 15<br>Using Wireless in Monitoring<br>Applications 16<br>Applying Wireless Technology to Horizontal<br>Applications 16<br>Using Wireless in Messaging 17<br>Using Wireless for Mapping 17<br>Using Wireless for Web Surfing 17<br>Exploring This Book on Wireless 18<br>xiii<br><br>Summary 19<br>Solutions Fast Track 20<br>Frequently Asked Questions 21<br>Chapter 2 Radio Elements and Frequency Spectrums 23<br>Introduction 24<br>Learn the Properties of Transmitting Radio Signals Over EM Waves 24<br>Waveforms<br>Anatomy of a Waveform 25<br>Modulating a Radio Signal 27<br>a = Amplitude<br>Propagating a Strong Radio Signal 34<br>v = Velocity of Propagation<br>Understanding Signal Power and<br>τ = Period<br>Signal-to-Noise Ratio 35<br>λ = Wavelength<br>Attenuation 36<br>? = Frequency<br>Rain Attenuation 39<br>Bouncing 39<br>Refracting 41<br>Line of Sight 42<br>Penetration 43<br>Understanding the Wireless Elements 45<br>Generic Radio Components 45<br>Antennas 49<br>Omnidirectional Antennas 50<br>Directional Antennas 51<br>Base Stations and Mobile Stations 56<br>Access Points 57<br>Channelizing the Frequency Spectrum 57<br>Channelizing 59<br>Channel Bandwidth 59<br>Channel Spacing and Buffer Zones 60<br>Multichannel Systems and Channel<br>Offsets 61<br>Extending the Number of Channels<br>(Frequency Reuse) 61<br>Seven Cell Frequency Reuse 62<br>Multiple Accessing 63<br><br>152_wan_toc 6/22/01 4:54 PM Page xv<br>Contents xv<br>Regulating Wireless Communications 64<br>Regulatory Agencies 64<br>The Need to Know 65<br>Regulations for Low Power,Unlicensed<br>Transmitters 66<br>Summary 68<br>Solutions Fast Track 69<br>Frequently Asked Questions 71<br>Chapter 3 TCP/IP and the OSI Model 73<br>Learn to Configure<br>Introduction 74<br>and Maintain Routes<br>Exploring the OSI and DoD Models 74<br>for Full Connectivity<br>Layer 1:The Physical Layer 75<br>Layer 2:The Data-Link Layer 75<br>PC<br>Layer 3:The Network Layer 77<br>Layer 4:The Transport Layer 78<br>T3<br>A<br>T1<br>Layer 5:The Session Layer 78<br>F<br>T3<br>E<br>B<br>Layer 6:The Presentation Layer 79<br>D<br>T3<br>Layer 7:The Application Layer 80<br>T1<br>C<br>T3<br>OSI and DoD Correlation 81<br>Understanding the Network Access Layer 81<br>Server<br>Using Bridging 82<br>The Ethernet Protocol 85<br>Static Routing in a<br>Understanding the ARP Process 86<br>Multihop, Multipath<br>Network<br>Wireless Protocols 87<br>Other Network Access Protocols 88<br>Understanding the Internet Layer 88<br>The Internet Protocol 89<br>IP Addressing 91<br>Conserving Address Space with VLSM 93<br>Routing 95<br>The Internet Control Message Protocol 101<br>Understanding the Host-to-Host Layer 101<br>User Datagram Protocol 102<br>Transmission Control Protocol 102<br>Managing the Application Layer 105<br>Monitoring Tools:SNMP 105<br><br>152_wan_toc 6/22/01 4:54 PM Page xvi<br>xvi Contents<br>Assigning Addresses with DHCP 105<br>Conserving with Network Address<br>Translation 106<br>Summary 110<br>Solution Fast Track 111<br>Frequently Asked Questions 113<br>Chapter 4 Identifying Evolving Wireless<br>Technologies and Standards 115<br>Understand Bluetooth<br>Introduction 116<br>Piconet and Scatternet<br>Fixed Wireless Technologies 117<br>Configuration<br>Multichannel Multipoint Distribution Service 117<br>Local Multipoint Distribution Services 119<br>Scatternet<br>Wireless Local Loop 120<br>Piconet 1 Piconet 2<br>Point-to-Point Microwave 121<br>Legend<br>P S<br>SB<br>SB<br>Wireless Local Area Networks 122<br>Master<br>M<br>S<br>Slave<br>10 m<br>S M<br>M S<br>Why the Need for a Wireless LAN Standard? 123<br>P<br>Parked<br>S S<br>Standby<br>SB<br>What Exactly Does the 802.11 Standard<br>S P<br>Define? 125<br>Does the 802.11 Standard Guarantee <br>Compatibility across Different Vendors? 128<br>802.11b 130<br>802.11a 131<br>802.11e 132<br>Developing WLANs through the 802.11<br>Architecture 133<br>The Basic Service Set 133<br>The Extended Service Set 135<br>Services to the 802.11 Architecture 135<br>The CSMA-CA Mechanism 138<br>The RTS/CTS Mechanism 138<br>Acknowledging the Data 139<br>Configuring Fragmentation 140<br>Using Power Management Options 140<br>Multicell Roaming 140<br>Security in the WLAN 141<br><br>152_wan_toc 6/22/01 4:54 PM Page xvii<br>Contents xvii<br>Developing WPANs through the 802.15<br>Architecture 143<br>Bluetooth 144<br>HomeRF 147<br>High Performance Radio LAN 147<br>Mobile Wireless Technologies 148<br>First Generation Technologies 150<br>Second Generation Technologies 150<br>2.5G Technology 150<br>Third Generation Technologies 151<br>Wireless Application Protocol 151<br>Global System for Mobile Communications 153<br>General Packet Radio Service 155<br>Short Message Service 155<br>Optical Wireless Technologies 156<br>Summary 157<br>Solutions Fast Track 159<br>Frequently Asked Questions 163<br>Chapter 5 Designing a Wireless Network 165<br>Introduction 166<br>Create a Detailed<br>Exploring the Design Process 166<br>Physical Design<br>Conducting the Preliminary Investigation 167<br>Performing Analysis of the Existing<br>Equipment model<br>Environment 168<br>Cabling details<br>Creating a Preliminary Design 169<br>Rack details<br>Finalizing the Detailed Design 169<br>Environment<br>Executing the Implementation 170<br>requirements<br>Capturing the Documentation 171<br>Physical location of<br>Identifying the Design Methodology 172<br>devices<br>Creating the Network Plan 173<br>Detailed RF design<br>Gathering the Requirements 173<br>Baselining the Existing Network 175<br>Analyzing the Competitive Practices 176<br>Beginning the Operations Planning 176<br>Performing a Gap Analysis 176<br>Creating a Technology Plan 177<br><br>152_wan_toc 6/22/01 4:54 PM Page xviii<br>xviii Contents<br>Creating an Integration Plan 178<br>Beginning the Collocation Planning 178<br>Performing a Risk Analysis 179<br>Creating an Action Plan 179<br>Preparing the Planning Deliverables 180<br>Developing the Network Architecture 180<br>Reviewing and Validating the Planning<br>Phase 181<br>Creating a High-Level Topology 181<br>Creating a Collocation Architecture 182<br>Defining the High-Level Services 182<br>Creating a High-Level Physical Design 183<br>Defining the Operations Services 183<br>Creating a High-Level Operating Model 184<br>Evaluating the Products 184<br>Creating an Action Plan 185<br>Creating the Network Architecture<br>Deliverable 186<br>Formalizing the Detailed Design Phase 186<br>Reviewing and Validating the Network<br>Architecture 186<br>Creating the Detailed Topology 187<br>Creating a Detailed Service Collocation<br>Design 188<br>Creating the Detailed Services 188<br>Creating a Detailed Physical Design 189<br>Creating a Detailed Operations Design 190<br>Creating a Detailed Operating Model<br>Design 190<br>Creating a Training Plan 191<br>Developing a Maintenance Plan 192<br>Developing an Implementation Plan 192<br>Creating the Detailed Design Documents 192<br>Understanding Wireless Network Attributes<br>from a Design Perspective 193<br>Application Support 194<br>Subscriber Relationships 196<br><br>152_wan_toc 6/22/01 4:54 PM Page xix<br>Contents xix<br>Physical Landscape 197<br>Network Topology 200<br>Network Security 201<br>Summary 203<br>Solutions Fast Track 204<br>Frequently Asked Questions 206<br>Chapter 6 Designing a Wireless Enterprise<br>Use Two Wireless<br>Network: Hospital Case Study 209<br>Outdoor Routers to<br>Introduction 210<br>Create Redundancy<br>Applying Wireless in an Enterprise Network 210<br>Introducing the Enterprise Case Study 211<br>To Building 100 To Main Hospital11 Mbps link<br>Building 100 Router<br>Assessing the Opportunity 211<br>To Building 101<br>To Building 101<br>Evaluating Network Requirements 213<br>To Building 200<br>Main Hospital Router<br>Assessing the Satellite Buildings’Physical<br>To Building 201<br>Landscape 214<br>To Building 300<br>Evaluating the Outside Physical Landscape 214<br>To Building 301<br>Evaluating the Current Network 216<br>Evaluating the Hospital Conference Room<br>Networking Landscape 216<br>Designing a Wireless Solution 217<br>Project 1:Providing Satellite Building Access 218<br>Project 2:Providing Wireless Technology<br>to the Conference Rooms 219<br>Project 3:Providing Building-to-Building<br>Connectivity 220<br>Describing the Detailed Design of the<br>Building Links 222<br>Implementing and Testing the Wireless Solution 224<br>Project 1:Implementing the Satellite<br>Building LAN Access 224<br>Project 2:Implementing the Hospital<br>Conference Room 224<br>Project 3:Implementing the<br>Building-to-Building Connectivity 225<br>Reviewing the Hospital’s Objectives 227<br>Lessons Learned 228<br><br>152_wan_toc 6/22/01 4:54 PM Page xx<br>xx Contents<br>Summary 229<br>Solutions Fast Track 230<br>Frequently Asked Questions 232<br>Chapter 7 Designing a Wireless Industrial<br>Network: Retail Case Study 233<br>Create an Installation<br>Introduction 234<br>Checklist and Verify<br>the Steps on the List<br>Applying Wireless Technology in an Industrial<br>Network 235<br>Set up the IP<br>Introducing the Industrial Case Study 235<br>information<br>Assessing the Opportunity 236<br>Install the access points<br>Defining the Scope of the Case Study 238<br>Install the AP Manager<br>Reviewing the Current Situation 238<br>software<br>Designing and Implementing the Wireless<br>Test the wireless<br>Network 239<br>network<br>Creating the High-Level Design 239<br>Review the client’s<br>Creating a Detailed Design 240<br>objectives<br>Obtaining a Physical Map 242<br>Determining User Density 247<br>Identifying Constraints 248<br>Conducting the Walk-Through 249<br>Identifying RF Interface Sources 249<br>Plan the RF Pattern for the Network 249<br>Planning the Equipment Placement 250<br>Determining Where to Place the Access<br>Points 251<br>Determining the RF Channel<br>Optimization 254<br>Identifying IP Addresses 255<br>Implementing the Wireless Network 255<br>Selecting the Hardware 256<br>Installing the Wireless Components 258<br>Setting Up IP Information 258<br>Installing the Access Points 258<br>Install the AP Manager Software 260<br>Installing the PC Card in Shipping/<br>Receiving 260<br><br>152_wan_toc 6/22/01 4:54 PM Page xxi<br>Contents xxi<br>Testing the Wireless Network 260<br>Reviewing the Client’s Objectives 261<br>Lessons Learned 262<br>Summary 263<br>Solutions Fast Track 264<br>Frequently Asked Questions 266<br>Chapter 8 Designing a Wireless Campus<br>Network: University Case Study 269<br>Introduction 270<br>Applying Wireless Technology in a Campus<br>Network 270<br>Introducing the Campus Case Study 271<br>Establish High-Level<br>Assessing the Opportunity 271<br>Inter-Building<br>Defining the Scope of the Case Study 272<br>Connectivity<br>Designing the Wireless Campus Network 273<br>The Design Approach 273<br>Field House<br>(Basketball)<br>Liberal Arts<br>Determining the Functional Design<br>Requirements 273<br>Engineering Biological Sciences<br>Tracking the Administration Needs 274<br>Tracking the Athletic Needs 275<br>inistration Building<br>Adm<br>Student Union<br>Tracking the Academic Department<br>Needs 276<br>Internet<br>Tracking Student Union Needs 277<br>200 Meters<br>Tracking Student Needs 277<br>StadiumDorms<br>Constraints and Assumptions 277<br>Identifying the Assumptions 279<br>Identifying the Constraints 281<br>Planning the Equipment Placement:Detailed<br>Design Requirements 283<br>Providing Detailed Administration<br>Requirements 283<br>Providing Detailed Athletic <br>Department Requirements 285<br>Providing Detailed Academic <br>Department Requirements 288<br><br>152_wan_toc 6/22/01 4:54 PM Page xxii<br>xxii Contents<br>Providing Detailed Student Union<br>Department Requirements 290<br>Providing Detailed Student Requirements 291<br>Implementing the Wireless Campus Network 292<br>Implementing the Physical Deployment 293<br>Implementing the Logical Deployment 294<br>Lessons Learned 295<br>Summary 296<br>Solutions Fast Track 297<br>Frequently Asked Questions 299<br>Chapter 9 Designing a Wireless Home <br>Network: Home Office Case Study 301<br>Learn to Build a<br>Introduction 302<br>Wireless Home<br>Network<br>Advantages of a Home Network 302<br>Advantages of a Wireless Home Network 304<br>Assembling the<br>Introducing the Wireless Home Network<br>network components<br>Case Study 305<br>Determining<br>Assessing the Opportunity 305<br>Broadband<br>Defining the Scope of the Case Study 306<br>configuration<br>Designing the Wireless Home Network 306<br>Installing the hardware<br>Determining the Functional Requirements 307<br>Installing and<br>Determining the Needs of Management 307<br>configuring the<br>Determining the Needs of the Family 308<br>software<br>Talking to the IT Department 308<br>Testing the network<br>Creating a Site Survey of the Home 309<br>Assessing the Functional Requirements 310<br>Analyzing the Existing Environment 310<br>Identifying Current Technology Options<br>and Constraints 312<br>Investigating Costs 313<br>Weighing Costs and Benefits 313<br>Assessing the Existing Environment 314<br>Developing a Preliminary Design 315<br>Choosing Vendor Solutions 317<br>Developing a Detailed Design 318<br>Implementing the Wireless Home Network 319<br><br>152_wan_toc 6/22/01 4:54 PM Page xxiii<br>Contents xxiii<br>Assembling the Network Components 319<br>Determining Broadband Configuration 320<br>Installing the Hardware 321<br>Installing and Configuring the Software 322<br>Installing and Configuring the Software<br>for the Home Firewall 322<br>Installing and Configuring the Software<br>for the Wireless Access Point 324<br>Testing the Network 326<br>Designing a Wireless Home Network for Data,<br>Voice,and Beyond 326<br>Current State of the Home Wireless<br>Marketplace 327<br>A Proposed Solution for the Future 329<br>Lessons Learned 330<br>Summary 332<br>Solutions Fast Track 332<br>Frequently Asked Questions 335<br>Designing a Wireless Network Fast Track 337<br>Index 357

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值